I am trying to insert list of items from dev.test1 table, but I am struggling with logic ...
Face following problems:
- Before insert statements I would like to add "if not exists" - select content in dev.qa_postmetas
- f.URL which I am getting in second query is not coming from correct row in dev.test1 - If want to select f.URL where f.title = b.title
Query:
INSERT INTO dev.qa_posts (type, categoryid, userid, created, title, content, tags)
(SELECT 'Q_QUEUED', '1', '3', NOW(), f.title, f.img, f.tagsv
FROM dev.test1 f)
LIMIT 1;
INSERT INTO dev.qa_postmetas (postid, title, content)
(select MAX(b.postid) , 'qa_q_extra',f.URL
from dev.qa_posts b
left JOIN dev.test1 as f on b.postid = f.id)
LIMIT 1 ;
Any assistance will be appreciated