Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: (OT) MySQL: delete from multiple tables

by jhourcle (Prior)
on Mar 14, 2005 at 15:28 UTC ( #439306=note: print w/ replies, xml ) Need Help??


in reply to (OT) MySQL: delete from multiple tables

The correct delimiter in SQL is single quotes.

DELETE FROM table1 WHERE data_id='111'; DELETE FROM table2 WHERE data_id='111'; DELETE FROM table3 WHERE data_id='111';

mySQL will support deletes from multiple tables, if you're using mySQL 4.0 or later, but I don't suggest it, as it can lock you into using mySQL, and it would mean that should you want to change out your backend, you'll have to go through and remove every mySQL-ism in your code. I find it better to be database-ambiguous unless it's something that you can't do efficiently without it.

Update: I stand corrected -- recent versions of mySQL supports double quotes as a delimiter. I would still advise against it, so you don't have problems should you later move to Oracle, or some other less forgiving database.


Comment on Re: (OT) MySQL: delete from multiple tables
Download Code
Re^2: (OT) MySQL: delete from multiple tables
by Jasper (Chaplain) on Mar 14, 2005 at 16:43 UTC
    Have you tried using double quotes in mySQL? I'm pretty sure it works. And I don't think you mean 'delimiter', either. You probably mean something to do with quoting. Whatever, he should be using placeholders.

    (A problem I see is that he has a ';' on the end, and if you pass that in via DBI or whatever, it'll screw things up)

    OK, maybe delimiter might be the right word. I've been wrong before :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://439306]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (14)
As of 2014-08-21 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (142 votes), past polls