Jump to content

Simple query on two tables?


Mr Chris

Recommended Posts

Hello,

 

Hopefully an easy one.  Say I want to search two tables for the same thing, where each of the tables has the column 'name' in it:

 

How would I correctly do it, I tried:

 

SELECT *
FROM table1, table2
WHERE table1.name = 'John'
OR table2.name = 'John'

 

But this brings back results for table1 and table2 in a single row, even though the result returned should just be from table2 as that's the only occurrance of John?

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/232660-simple-query-on-two-tables/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.