Gerald,

Your right. You and Roger hit it on the head. Stupid me miss read Roger's original post.

Last night I was banging my head on the left and right joins but I didn't understand it until I read Gerald's last note. Plus I didn't realize you can put two conditions in the ON clause which is why I didn't get Roger's post.

Thank you very much guys. You saved the day.

Joe

On Friday, January 16, 2004, at 12:31 PM, gerald_clark wrote:

That is the whole point of a left join.
It joins to a null record when the appropriate right record does not exist.


sulewski wrote:

Roger,

Thank you for the feedback. But unfortunately this doesn't work. The problem is that rid will never be null. I'm trying to find the item in tab1 where a link cannot be created in tab2 where tab2.rid=tab1.id and tab2.vid=46 because there is no record in tab2. Not that the record may have null values. I did try what you said and it didn't work.

But thanks,

Joe

On Friday, January 16, 2004, at 11:49 AM, Roger Baklund wrote:

* sulewski
[...]

What I need is all records in table 1 that will
not link to table 2 such that relid=rid and vid=46


Sounds like a job for LEFT JOIN...?

Join to the rows you do NOT want with a left join, and put as a condition in
the WHERE clause that a joined column IS NULL. Something like this:


SELECT tab1.*
  FROM tab1
  LEFT JOIN tab2 ON
    tab2.rid=tab1.id AND
    tab2.vid=46
  WHERE
    tab2.rid IS NULL

--
Roger






--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to