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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql query ??

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have 2 tables in mysql
table 1 name: ex_main
contains ex_id and author_id
table 2 name: ex_author
contains author_id and author_name

i want to query to find all ex_id's in ex_main that
have the same name as my query

tried this (does not work...)
SELECT EX_MAIN.EX_ID FROM EX_MAIN AND EX_AUTHOR WHERE EX_AUTHOR.NAME LIKE '%$NAME%' AND EX_AUTHOR.AUTHOR_ID LIKE EX_MAIN.AUTHOR_ID

where the %'s are the wildcards and the $NAME is the variable in PHP that resolves the the correct string - i know these work and are not the problem.

i have verified the data in my mysql database and i can get this to work with 2 separate queries - is it possible to have this done with one query?

TIA! ;-)

--Mike
 
I think ther might be a syntax error.
When you list the FROM tables you should seperate them with a comma not and.
e.g.
SELECT EX_MAIN.EX_ID
FROM EX_MAIN , EX_AUTHOR
WHERE EX_AUTHOR.NAME LIKE '%$NAME%'
AND EX_AUTHOR.AUTHOR_ID LIKE EX_MAIN.AUTHOR_ID
[sig]<p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>Top man[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top