Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subquery Help Needed. Online docs useless

Status
Not open for further replies.

darwin2kx

Technical User
Sep 28, 2006
3
CA
I have two tables that I want to select from. The first is a list of characters, with the alignment saved as a character code i.e. LG.
The second table is a list of character codes and proper texts i.e. Lawful Good.

What I want to do is have the MySQL query cross reference these two things, and pass the long_name with the results, replacing the character code.
So that I don't have to do it in the PHP code instead.

Anyway, here is my feeble attempt at a query. I have something very wrong here I know. However, the online docs I've dug through have been very unhelpful to this point.

SELECT *
FROM char_master_list c(
SELECT long_name
FROM ref_align r
WHERE c.align = r.dc
)
ORDER BY name ASC
LIMIT 0 , 25
 
Can you show us the schema of the two tables and their FK relationship - it seems like you are looking for a JOIN

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Code:
SELECT c.please
     , c.list 
     , c.only
     , c.the
     , c.columns
     , c.you
     , c.need
     , c.name
     , r.long_name
  FROM char_master_list as c
inner
  join ref_align as r
    on r.dc = c.align 
ORDER 
    BY c.name ASC LIMIT 25

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top