|
-
Dec 31st, 2008, 09:52 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] SQL - DELETE statement with JOINS in it
Hi all,
I have these database tables in a MySQL database (version 5.0.67-community):
quotes (fields: id, customer_info_id, vehicle_id)
customer_info (fields: id, first_name, last_name, address_id)
addresses (fields: id)
vehicles (fields: id)
One quote = 1 record in each of those tables, all linked.
What I want to do is delete all records from all tables if the first or last name of the customer is 'test'. It seems too complicated to do it all in one query so I've tried doing one query per table like this:
Code:
DELETE FROM
vehicles b
LEFT JOIN
quotes a ON a.vehicle_id = b.id
LEFT JOIN
customer_info c ON a.customer_info_id = c.id
WHERE
c.first_name = 'test' OR
c.last_name = 'test'
But the MySQL server gives a syntax error on that.
Any help is appreciated, cheers!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|