SELECT * FROM tableFoo
LEFT JOIN tableBar ON tableFoo.commonColumn = tableBar.commonColumn
WHERE tableBar.commonColumn IS NULL
Above will select records, I would like to insert Code below will insert id to third table.
INSERT IGNORE INTO jos_mt_links (link_id,link_name,alias)
VALUES(NULL,'tex2','hello'); # generate ID by inserting NULL
INSERT INTO jos_mt_cl (link_id,cat_id)
VALUES(LAST_INSERT_ID(),'88'); # use ID in second table
How do I combine these too? Thx
Again, I add this note here, how do I combine these queries tohether. All of them, including the first query (SELECT *....)
Something like this: SELECT records, then insert them, and also insert this....