Forum Moderators: open
i have a table with the following columns
keywordrank_id (primary key)
article_id (the article reference primary key)
Keyword_id (1 = backpain) (2= fitness) etc --(just the number mind ya)
keyword_rank (this is either 0 or 1 depending on if a checkbox has been checked as related)
the table contains data for keywords that relate articles
all is well but if i am trying to add a new keyword to the table, so i'm trying to insert a new row for every article_id that does not have the option of checking this new keyword.
I have managed to single out the rows in the table that do have this keyword with the following statement
SELECT article_id FROM keyword_rank WHERE (keyword_id = 6) Group By article_id
this returns two rows 66 and 67
by changing (keyword_id = 6) to (keyword_id != 6)
i was hoping that this would select all the other rows excluding 66 and 67, but alas no,it selects all the rows. i was thinking i might need to use two statements,but have hit a bit of a mental block.
does that make any sense whatsoever to anyone out there?
INSERT INTO mytable
SELECT article_id, SomeValueForKeywordID,SomeValueForKeywordRank
FROM mytable
WHERE article_id NOT IN (
SELECT article_id FROM keyword_rank WHERE (keyword_id = 6) Group By article_id
)