Simon wrote:
Hi all,
Have been trying to get the syntax of a delete query in MySQL for days
and get nothing but errors. Any MySQL Gurus out there can help? I have
tried all the versions and variations I can find on the web site, this
is V3 of MYSQL. I either get a syntax error and the query seems to be
truncated or I get an invalid table name. I have tried standard SQL
syntax, have tried the 'USING' command etc etc. Any ideas?

Table 1: user
Table 2: user_preferences

I want to delete records from the user-preferences table based on a
field 'department' in the user table being '2000'
The table can be joined from user.id=user_preferences_userid

delete from user_preferences where user.id in (select user.id from user where department=2000);

This works in PostgreSQL, or does MySQL still not have sub-selects - one reason (the other being transaction processing) why I chose PGSQL over MySQL many years ago. [ RDW from database flame war :) ]


------------------------------------
OLMC
Simon Bryan
IT Manager
[EMAIL PROTECTED]
LMB 14
North Parramatta
Direct Number:88381200
SwitchBoard: 96833300
fax: 98901466
mobile: 0414238002
------------------------------------


--
Howard.
LANNet Computing Associates - Your Linux people <http://lannetlinux.com>
When you want a computer system that works, just choose Linux;
When you want a computer system that works, just, choose Microsoft.
--
Flatter government, not fatter government; abolish the Australian states.

--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to