Jump to content

search multiple tables MYSQL database


jurgen

Recommended Posts

$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!

Link to comment
Share on other sites

\"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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.