Jump to content


Photo

Query Help please.


  • Please log in to reply
1 reply to this topic

#1 redneonrt

redneonrt
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 27 April 2006 - 06:06 PM

I have two MySql tables and I would like a query that selects everything from table 1 but only if the table1.id from table 1 does not exist in table2.id.

Any suggestions?

#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 27 April 2006 - 06:30 PM

use left join

$sql = "SELECT fieldname
        FROM table1
        LEFT JOIN table2 ON table1_id = table2_id
        WHERE table2_id IS NULL";

Ray




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users