Jump to content


search multiple tables MYSQL database

  • Please log in to reply
1 reply to this topic

#1 jurgen

  • New Members
  • Pip
  • Newbie
  • 1 posts
  • LocationNetherlands

Posted 13 August 2003 - 02:54 PM

$query = \"SELECT * FROM intranet_opdrachten AND intranet_bedrijven WHERE omschrijving OR opdrachtgever LIKE \'%$zoeken%\'\";

This is not the right query to search in both tables (intranet_opdrachten AND intranet_bedrijven). Hopefully someone knows the solution to this problem. I can search in one table, but two seems to be difficult.

Thank you!

#2 rhysmeister

  • Members
  • PipPipPip
  • Advanced Member
  • 51 posts
  • LocationEngland

Posted 13 August 2003 - 03:55 PM

\"SELECT * FROM intranet_opdrachten LEFT JOIN intranet_bedrijven ON intranet_opdrachten.id=intranet_bedrijven.id WHERE intranet_opdrachten.omschrijving OR intranet_opdrachten.opdrachtgever OR intranet_bedrijven.omschrijving OR intranet_bedrijven.opdrachtgever LIKE \'%$zoeken%\'\";

Something like this should do. I haven\'t had time to test it so can\'t be 100% sure. You need to join the two tables by a appropriate field. Do a little bit of research on table joins and you should be ok. Hope this helps.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users