I'm hacking on my Zotero database with sqlite3, since the Zotero gui still doesn't support editing multiple records at once.  Current task is finding all items from a particular journal, separating out the ones that don't yet have a value for journalAbbreviation, and adding the correct abbreviation.  Here are the relevant tables:
fields (fieldID, fieldName, fieldFormatID)
itemData (itemID, fieldID, valueID)
itemDataValues (valueID, value)
Here is my query to find all the records I want:
SELECT itemData.itemID
FROM fields JOIN itemData JOIN itemDataValues 
WHERE (fields.fieldname IN ('publicationTitle'))  
AND (fields.fieldID = itemData.fieldID) 
AND (itemData.valueID = itemDataValues.valueID) 
AND (itemDataValues.value IN ('The Journal of the Acoustical Society of America'));
Now that I have that list of itemIDs, I want to add a bunch of entries to the itemData table.  Schematically I want to do this:
INSERT INTO itemData (itemID, fieldID, valueID)
VALUES (A,X,Y),(B,X,Y),(C,X,Y), ... (W,X,Y);
where X is the fieldID for 'journalAbbreviation' and Y is the valueID for 'J. Acoust. Soc. Am.' (I know how to get those values).  How can I write this INSERT INTO statement to replace A, B, C, etc with the itemIDs from my SELECT query above?
note: some of the records already have the journal abbreviation in there.  I've only been writing SQL for a few days, so I don't know if it will cause problems to try to INSERT a record that already exists in the table (I'm assuming it will, based on a vague understanding of primary keys and the fact that the schema section in the itemData table includes a line PRIMARY KEY (itemID, fieldID)).  So it may be necessary to first exclude those itemIDs that already have a record in itemData that includes X as fieldID.
 
     
     
     
    