I have 50,000 user records that contain a field booklist
with a list of comma separated bookIDs
.
I have a book
table with bookID
as the primary key with about 100,000 records.
I want to loop over all the users and their booklist
to find out if there is a matching bookID
in the book
table. If it is not in the book
table, I need to insert that bookID
into the book
table.
Can this be done with SQL alone?
If I use PHP, would I be better off combining all the lists of bookID
into a long string or array and then looping over all bookID
in the book
table to find the missing ones?
This is a one time script, so the simpler the better ;-)