kingnutter Posted August 4, 2009 Share Posted August 4, 2009 Hi everyone, I have given this a good Googling but not found the answer. I am trying to query two tables to produce one result, hopefully in one seamless query. Below is a hybrid Plain English / PHP version of exactly what I am trying to achieve. { $data = mysql_query("SELECT moj_id, track_artist, track_title FROM tracks WHERE upper(track_artist) LIKE '%$find%' OR upper(track_title) LIKE '%$find%' THEN SELECT moj_title FROM mojocd WHERE moj_id IS THE SAME AS THE ONE IN THE FIRST PART OF THIS QUERY"); } Any pointers? Quote Link to comment https://forums.phpfreaks.com/topic/168845-help-needed-to-query-two-tables-at-once/ Share on other sites More sharing options...
Psycho Posted August 4, 2009 Share Posted August 4, 2009 Learn how to use JOINS to really utilize a database SELECT t.moj_id, t.track_artist, t.track_title, m.moj_title FROM tracks t JOIN mojocd m ON t.moj_id = m.moj_id WHERE upper(t.track_artist) LIKE '%$find%' OR upper(t.track_title) LIKE '%$find%' Quote Link to comment https://forums.phpfreaks.com/topic/168845-help-needed-to-query-two-tables-at-once/#findComment-890853 Share on other sites More sharing options...
kingnutter Posted August 4, 2009 Author Share Posted August 4, 2009 Ah. Very interesting. I shall do so and report back if I get jumbled. Thanks for the speedy reply. Quote Link to comment https://forums.phpfreaks.com/topic/168845-help-needed-to-query-two-tables-at-once/#findComment-890856 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.