MySQL insert record to one table to another if postid is not exist
0
$begingroup$
Is there any way to write query in better way than this if I want to insert postid from posts table to star_ratings table if the postid is not exists in star_ratings table. INSERT INTO star_ratings(post_id) SELECT postid FROM posts WHERE type in ('D', 'B') AND postid NOT IN (SELECT post_id FROM star_ratings) ORDER BY postid ASC
mysql
share | improve this question
asked 11 mins ago
pixelngrain pixelngrain
208 1 11
$endgroup$