On Fri, 20 Oct 2006, [EMAIL PROTECTED] wrote:

Ok. Just found I gave wrong info. To make my life easier, the person who
created db named cust_id in 'orders' table as SoldTo

[EMAIL PROTECTED]

in this case,
select cust_id from customers
where cust_id not in
  (select Soldto from orders);

will not work

:(


Maybe I'm not understanding you but as long as Soldto is cust_id just with a different column name it will still work.

The subquery will result in a list of values and then the "NOT IN" clause will check if your cust_id is "not in" that list.

For more info check out:
http://dev.mysql.com/doc/refman/5.0/en/subqueries.html



On Fri, 20 Oct 2006, [EMAIL PROTECTED] wrote:

hi to all,
I have table customers (PK cust_id)
I have table orders (PK order_id, FK cust_id)

I need query that will selecct all customers from 'customers' they don't
have any order, there is not their cust_id in 'orders'.

couls somebody help me?

thanks.

-afan

I think the most explicit way is with a sub select:

select cust_id from customers where
cust_id not in
        (select cust_id from orders);

-w

--
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]






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

Reply via email to