After a whole day of work I got stuck into one query which I'm sure it's simple but I can't getthe right result. Maybe I'm tired, I need a light on this. I have 2 tables with a relation between them: questions (ID, question) and answers (ID, ID_question, visitor_IP). each time a visitor enters an answer I store the ip address in order to not show the same question twice. My damn question is: How do I select the questions from the first table (questions) that are not answered (the visitor's ip and it's ID are not stored in the answers table. Thank you for your help, if any
SELECT q.* FROM questions q WHERE NOT EXISTS(SELECT * FROM answers a WHERE a.id_question = q.id AND visitor_ip = 'x.x.x.x')