On Mon, Apr 4, 2011 at 12:26 PM, Simon Slavin wrote:
> But he's combining two INSERTs into one. What I think he needs is first an
> INSERT OR FAIL to possibly add a new person, and then an INSERT ... SELECT
> which looks up that person's ID.
I didn't see that in the
On 4 Apr 2011, at 6:01pm, Nico Williams wrote:
> On Mon, Apr 4, 2011 at 11:25 AM, Simon Slavin wrote:
>> Probably not. Don't try to turn SQL into a procedural language. Do the
>> SELECT that tells you whether the record exists and gives you the
>> information you need
On Mon, Apr 4, 2011 at 11:25 AM, Simon Slavin wrote:
> Probably not. Don't try to turn SQL into a procedural language. Do the
> SELECT that tells you whether the record exists and gives you the information
> you need if it does, then do whatever INSERTs you need to do.
On 4 Apr 2011, at 4:26pm, Marcelo Serrano Zanetti wrote:
> About the "new" item, yes I do compare some specific fields and not the
> primary key. For example name and surname of a person ... I look in the
> database for such a person ... if yes I return her id ... if not I
> include her and
On 04/04/2011 05:16 PM, Robert Poor wrote:
> @Marcelo:
>
> Going back to your original question: do you really only want to
> insert one item at a time? If so, I think your question has been
> answered reasonably well.
>
> BUT: if you have a large number of items, and you want to insert items
>
@Marcelo:
Going back to your original question: do you really only want to
insert one item at a time? If so, I think your question has been
answered reasonably well.
BUT: if you have a large number of items, and you want to insert items
that aren't yet in the table, then you can do it
On 04/03/2011 09:05 PM, Petite Abeille wrote:
> On Apr 3, 2011, at 3:18 PM, Marcelo Serrano Zanetti wrote:
>
>> It does not work in this way ... could somebody tell me please what is
>> the correct sintax or whether this is possible at all.
> As mentioned, SQL is not a procedural language, so, no.
On Apr 3, 2011, at 3:18 PM, Marcelo Serrano Zanetti wrote:
> It does not work in this way ... could somebody tell me please what is
> the correct sintax or whether this is possible at all.
As mentioned, SQL is not a procedural language, so, no.
That said, you can achieve the same effect with
On Sun, Apr 3, 2011 at 3:49 AM, Marcelo S Zanetti wrote:
> IF 1==SELECT COUNT(*) from table
> WHERE item==new THEN SELECT itemID from tabel WHERE item==new ELSE
> INSERT INTO table (item) VALUES (new)
INSERT INTO t (item) SELECT :new WHERE NOT EXISTS (SELECT item FROM t
Hi
I would like to do the following
I have an item to insert in the table which will be inserted only if
this item is not yet in that table otherwise I would like to return the
item's key.
like that
IF 1==SELECT COUNT(*) from table WHERE item==new THEN SELECT itemID from
tabel WHERE
On 03/04/2011, at 6:49 PM, Marcelo S Zanetti wrote:
> I have an item to insert in the table which will be inserted only if this
> item is not yet in that table otherwise I would like to return the item's key.
>
> like that
>
> IF 1==SELECT COUNT(*) from table
> WHERE item==new THEN SELECT
On 04/03/2011 03:12 PM, Igor Tandetnik wrote:
> Marcelo S Zanetti wrote:
>> I
>> have an item to insert in the table which will be inserted only if this
>> item is not yet in that table otherwise I would like to return the
>> item's key.
>>
>> like that
>>
>> IF 1==SELECT
Marcelo S Zanetti wrote:
> I
> have an item to insert in the table which will be inserted only if this
> item is not yet in that table otherwise I would like to return the
> item's key.
>
> like that
>
> IF 1==SELECT COUNT(*) from table
> WHERE item==new THEN SELECT itemID
Hi
I would like to do the following
I
have an item to insert in the table which will be inserted only if this
item is not yet in that table otherwise I would like to return the
item's key.
like that
IF 1==SELECT COUNT(*) from table
WHERE item==new THEN SELECT itemID from tabel WHERE
14 matches
Mail list logo