On Sep 19, 2008, at 10:49 AM, Gordon Stewart wrote: > Hi, > > I'm following the example here :- > > http://forums.mysql.com/read.php?52,138724,138727#msg-138727 > > > I've been designing a SELECT query on two tables.. -It seems to be > working... But i want to confirm its correct before I do any UPDATE > commands > > > $query = " > SELECT q.question_id, q.question_text, q.is_approved, q.language > FROM questions AS q > LEFT JOIN questions_categories AS qc ON qc.question_id = > q.question_id > WHERE qc.question_id IS NULL"; > > Basically, Ive got 2 tables... > > q = Question ID, Text/title of question, approved (online) or not, > and language... > > qc = a question ID, and a category... > > my query produces 2 results (out of 2 records) > > Basically, I want to check the category database, & find all questions > IN the questions table, but not in the category table... > > & if so - set / add a new record in the categories database for the > question, & category '1'
Probably easier to do something like this: SELECT question_id, question_text, is_approved, language FROM questions WHERE question_id NOT IN (SELECT question_id FROM questions_categories) then do your insert from there. -D. Israel [EMAIL PROTECTED] http://www.customcodebydan.com AIM: JudoDanIzz [Non-text portions of this message have been removed]