Greetings, all.

I'm having trouble getting an insert statement to function properly, and 
am not sure if it is me, or this isn't supposed to be done.

This is not the complete database, but to keep this issue simple:

I have three tables:

artists (artistID integer, lastname text) contains 1, 'Weaver'
titles (titleID integer, title text) contains 1, 'Alien'
cast (castID, artistID)

I am experimenting with inserting data into the cast table using values 
that will be entered either by a user or selected from a list.  In the 
meantime, I am manually entering the values "Weaver" and "Alien" to 
acquire title ID number and artist ID to store into the cast table.

This simple statement works fine and yield the expected "1": insert into 
cast (titleID) select titleID from titles where title='Alien';

I get into trouble when I attempt to add the extra field: insert into 
cast (titleID, castID) select titleID from titles where title='Alien' 
select artistID from artists where lastname='Weaver';

I know that the above syntax is incorrect.  I have tried adding 
parentheses around the select statements (SELECT XXX), (SELECT XXX) and 
have tried the UNION in between, which I now understand adds separate 
rows into the table.  I assumed that I could replace simple values with 
SELECT statements, but either I am wrong, or I have bogus syntax.

I am new to using SQL outside of the "drag-and-drop" Access method, so 
this might be a silly question.

If this can't be done I suppose I could add one value as a SELECT 
statement, then try to locate that row in the table and do an UPDATE to 
the other column (in this case, the cast column) where I just inserted 
the data.

Thank you!
George R.






-- 
www.andforthelamb.org
www.outreachhockey.org

They deem me mad for I will not sell my days for gold; I deem them mad for they 
think my days have a price.


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to