Hello!
I have two tables. One contains invoices, one contains customers.
How do I delete customers that are not linked to any invoice.
The relation is one to many (invoices --> customers).
I can select them with:
select customers.* from customers left join invoices on
invoices.cust_id=customers.id where invoices.id is null
but
delete from customers left join invoices on invoices.cust_id=customers.id
where invoices.id is null
fails.
Regards, Tadej
/---------------------------------------------------------------------------
------------------/
I am knew to MYSQL, but does MYSQL support (not in) if that is so
you can do :
delete from customers where customer.id not in (select invoices.id from
invoices )
It is not a very good option, because in other database the operator NOT IN
could
carry a lot of OVERHEAD
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php