I have a query writing problem. My table:
-> table users_keyword_document document_id | users_keyword_id -------------+------------------ 65 | 1 65 | 2 66 | 1 66 | 3
I want to retrieve only the document with document_id 65
The search can only be done with the user keyword identifiers so users_keyword_id
My query :
SELECT document_id, users_keyword_id FROM users_keyword_document WHERE users_keyword_id IN (1,2);
Returns the following result :
document_id | users_keyword_id -------------+------------------ 65 | 1 65 | 2 66 | 1
Is there an easy way to do this?
I use PostgreSQL.
Thanks for your help.
3
Answers
Use HAVING as a condition that works on the group of records:
You can use the GROUP BY and HAVING clause method. Can you try this?