Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: Re: Re: Using placeholders in MySQL returning an error

by mpeppler (Vicar)
on Jan 16, 2004 at 19:00 UTC ( [id://321875]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Using placeholders in MySQL returning an error
in thread Using placeholders in MySQL returning an error

Well - injunjoel mentioned the possibility of using the INSERT into foo SET bar = ?, ... syntax to execute an insert with placeholders. I just wanted to point out that using INSERT ... SET ... is not part of the SQL standard (AFAIK). It may be tempting to use because it is of course very similar to UPDATE ... SET ... WHERE, but your code will not be portable to other database engines if you decide to use it.

As others have pointed out, it is always good to be explicit when writing SQL statements. This means writing

INSERT into the_table(foo, bar, baz) values(...)
instead of
INSERT into the_table values(...)
and
SELECT foo, bar, baz FROM the_table WHERE ...
instead of
SELECT * FROM the_table WHERE ...
It requires a little more typing, but it clarifies things, and will make errors more obvious.

Michael

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Using placeholders in MySQL returning an error
by bradcathey (Prior) on Jan 16, 2004 at 19:14 UTC
    Thanks for the explanation mpeppler, that was helpful, and points well taken. And hardburn was right, no code samples really necessary, but your examples didn't hurt .

    —Brad
    "A little yeast leavens the whole dough."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-26 04:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found