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."