Erica L Ridley <[EMAIL PROTECTED]> wrote:
> I need help with rewriting a sql query.  Nested queries that work in MS
> databases apparently do not work in MySQL databases.  Here is what I need
> in MS query pseudo code:
> 
> SELECT table1.myfield1, table2.myfield2 
> FROM table1, table2  
> WHERE table1.key=table2.key AND myfield1="something" 
> AND myfield2 NOT IN 
> (SELECT myfield2 FROM table3 WHERE table3.myfield3="whatever")
> 
> For example, if I wanted to get all Forum Posts (Table1)  for TopicA that
> do NOT have replies (Table3) by User1.
> 
> I have been going crazy trying joins - lefts, rights, inners, outers... 
> Any help would be greatly appreciated!!  

SELECT table1.myfield1, table2.myfield2
FROM table1 INNER JOIN table2 ON(table1.key=table2.key AND table1.myfield1="something")
LEFT JOIN table3 ON (table2.myfield2=table3.myfield2 AND table3.myfield3="whatever")
WHERE table3.myfield2 IS NULL;



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com




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

Reply via email to