At 7:37 AM -0500 9/24/99, Erik Andersson wrote:
>This is probably a rather simple SQL question. I think that my example will
>speak for it self. I need to insert three values into a table. Yet one of
>them is one that I want to grep from another table. It looks like this
>INSERT INTO orderrow (
>VALUES (SELECT customer_id FROM customer WHERE
>The documentation says this
> INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
> [INTO] tbl_name [(col_name,...)]
> VALUES (expression,...),(...),...
>... which I think is what I'm doing. The error I get is the following
>ERROR 1064: You have an error in your SQL syntax near 'SELECT customer_id
>FROM customer WHERE customer_login='erik'),(123,321)' at line 6
In that syntax, expression is an expression, not an entire SELECT
statement. You're doing the latter. However, you may be able to
achieve your goal by using the INSERT INTO ... SELECT ... FROM
form of insert. Check the manual again for the exact syntax.
In any case, you syntax is slightly off because you're specifying
one value list with a single element followed by a value list with
two elements, rather than a single value list with three elements.
Paul DuBois, paul@stripped