samedi 26 mars 2016

Dynamic Multi-row INSERT in SQLite with SELECT

I have a static table called SSJ which looks like:

ID   fSSID        tSSID
1    30000002     30000005
2    30000002     30002973
3    30000003     30000001

I'm trying to INSERT into a separate table tmpTable based on a SELECT for fSSID from SSJ. tmpTable has the structure:

id INTEGER, ssid NUM, wt NUM, prnt NUM

The insert I'm using looks like this:

INSERT INTO tmpTable (ssid, wt, prnt) VALUES ((SELECT tSSID FROM SSJ WHERE fSSID=30000002), 0, 30000002)

With this INSERT I'm expecting to see two new rows in tmpTable because the SELECT should garner two results from SSJ, id's 1 and 2, but I'm only getting one. This is only a minor example as in the actual SSJ table there could be many multiples of the same fSSID (or there could be only 1).

What am I overlooking here?

Aucun commentaire:

Enregistrer un commentaire