On Tue, Feb 24, 2009 at 5:19 PM, Leo Freitag <leofrei...@netcologne.de> wrote:
>
> Hallo,
>
> I'm trying to insert the highest value of tblName into tblZO.
>
> There fore I followed the hints in this article ...
> http://www.nabble.com/How-to-use-the-ROWID-of-the-last-inserted-row-for-FK-insert-into-other-tables--td19085514.html#a19085514
>
> ... but I got a error (see below)
>
> SQLite version 3.3.13
> Enter ".help" for instructions
> sqlite> create 'tblName' ('id' integer primary key, 'text' text);
> SQL error: near "'tblName'": syntax error
> sqlite> create table 'tblName' ('id' integer primary key, 'text' text);
> sqlite> insert into 'tblName' Values (NULL, 'one');
> sqlite> insert into 'tblName' Values (NULL, 'two');
> sqlite> insert into 'tblName' Values (NULL, 'three');
> sqlite> insert into 'tblName' Values (NULL, 'four');
> sqlite> insert into 'tblName' Values (NULL, 'five');
> sqlite> create table 'tblRefMaxName' ('ref' integer, 'nn' text);
> sqlite> insert into 'tblRefMaxName' Values (select max(id) from tblName,
> 'eins')

select max(id) from tblName, 'eins' is not a valid select statement.

Do the following instead --

insert into tblRefMaxName Values ((select max(id) from tblName), 'eins')

by putting parens around the select, you are now correctly passing two
values that tblRefMaxName expects.


> ;
> SQL error: near "select": syntax error
> sqlite>
>
> Can anybody help?
>
> Leo
> --
> View this message in context: 
> http://www.nabble.com/Error-on-INSERT-with-SELECT-Max%28id%29-FROM-...-tp22192949p22192949.html
> Sent from the SQLite mailing list archive at Nabble.com.
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
Puneet Kishor http://www.punkish.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to