Christophe De Troyer
Christophe De Troyer

Reputation: 2922

Use result of query with single result in SELECT

I'm using Sqlite and I found out that INSERT does not return the just inserted record with the automatically created primary key.

To solve this issue I found out I can use SELECT last_insert_rowid(). This returns the value that I need.

I need this value to update a field in the record of my database.

Is there any way I could form a SELECT query that has the result of that query built in?

UPDATE events SET url='query executed' WHERE eventId = <value of above query should come here>

Upvotes: 0

Views: 80

Answers (1)

wawek
wawek

Reputation: 1597

If SELECT last_insert_rowid() returns the value that you need then put it there as a subquery. Subquery must be in (your_subquery) brackets.

Upvotes: 2

Related Questions