Igor Korot wrote:
> Hi, ALL,
>
> sqlite> CREATE TABLE leagueplayers(id integer, playerid integer, value
> integer,
> currvalue double, foreign key(id) references leagues(id), foreign
> key(playerid)
> references players(playerid));
> sqlite> INSERT INTO leagueplayers VALUES(1,(SELECT playerid,value,currvalue
> FROM
> players));
> Error: table leagueplayers has 4 columns but 2 values were supplied
>
> AFAICT, I am trying to insert 4 values in the table.
No, you
1) insert *two* values: 1 and (SELECT) expression;
2) improperly use (SELECT) expression:
There are no array type in sqlite. Only single column results is allowed for
(SELECT) expression, e.g.:
sqlite> SELECT (SELECT 1,2);
Error: only a single result allowed for a SELECT that is part of an expression
Just only first discovered error can be returned (and in this case it was
inconsistent number of columns for insert).
> Does anybody have an idea what is wrong?
Correct:
INSERT INTO leagueplayers (id, playerid, value, currvalue)
SELECT 1, playerid,value,currvalue FROM players;
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users