With the comment that the insert or ignore method there will only work if 
there's an explicit unique constraint on your given criteria.


-----Original Message-----
From: sqlite-users [mailto:[email protected]] On 
Behalf Of Simon Slavin
Sent: Wednesday, April 26, 2017 4:46 PM
To: SQLite mailing list
Subject: Re: [sqlite] Equivalent syntax in sqlite


On 26 Apr 2017, at 9:42pm, Joseph L. Casale <[email protected]> wrote:

> Whats the trick with SQLites working set to format a single statement with 
> parameters
> where if a row exists for a given criteria, returns its Id, otherwise insert 
> and return the
> last_insert_rowid()?

It has to be two operations.

INSERT OR IGNORE INTO MyTable …;
SELECT rowid FROM MyTable WHERE …;

Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to