On 15/08/2011, at 10:40 PM, Simon Slavin wrote:
> which is why proper code should never do it in one instruction. You do the
> SELECT first, then use your programming language to do the right thing for
> each of the three cases where 0, 1 or more records are returned.
I disagree with this
On 15 Aug 2011, at 12:58pm, Igor Tandetnik wrote:
> Black, Michael (IS) wrote:
>> insert into orders (OrderNo,P_Id) select 12345,P_Id from persons where
>> LastName='Hansen';
>
> vs
>
>> INSERT INTO ORDERS (OrderNo, P_Id)
>> values (
>> 12345,
>> select P_Id from
From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on
behalf of Igor Tandetnik [itandet...@mvps.org]
Sent: Monday, August 15, 2011 6:58 AM
To: sqlite-users@sqlite.org
Subject: EXT :Re: [sqlite] Insert rows into a foreign key table
Black, Michael (IS) <michael.
Black, Michael (IS) wrote:
> insert into orders (OrderNo,P_Id) select 12345,P_Id from persons where
> LastName='Hansen';
vs
> INSERT INTO ORDERS (OrderNo, P_Id)
> values (
> 12345,
> select P_Id from persons where LastName = 'Hansen')
To the OP: note that there's a
-boun...@sqlite.org] on
behalf of David Westbury [pe8...@yahoo.com]
Sent: Sunday, August 14, 2011 10:46 PM
To: sqlite-users@sqlite.org
Subject: EXT :[sqlite] Insert rows into a foreign key table
For the two tables shown here, what sqlite INSERT statement would add a new
Order for person Hansen
David Westbury wrote:
> For example, why won't an embedded select statement similar to the following
> work?
>
> INSERT INTO ORDERS (OrderNo, P_Id)
> values (
> 12345,
> select P_Id from persons where LastName = 'Hansen')
Because it's not valid SQL. Try this one:
INSERT INTO
For the two tables shown here, what sqlite INSERT statement would add a new
Order for person Hansen? Is it
possible to add a new order with one sql statement or does it require
two statements?
The only way I have found to add a new order is
to first SELECT the P_Id for Hansen from the Persons
7 matches
Mail list logo