Searching high and low for an answer to this one and having no luck. I'm sure it can't be as complicated as I think it is.
I have one table with titles and codes. The codes are unique and can have more than one titlecode.
I want to be able to select those titles that have codes I list.
Titles Codes
-----------------------------------
Book1 001
Book2 010
Book2 020
Book2 021
Book3 030
Book3 040
So I want to be able to return Titles that have codes 020 and 021. Or whatever I list.
In this case it would just return Book2 as that Title has those two codes.
I initially tried
SELECT Titles FROM table WHERE Codes = 020 AND Codes = 021
but that returned zero results and I could see why. No row contains more than one Codes entry
SELECT Titles FROM table WHERE Codes = 020 OR Codes = 021
returns Titles that are either.
So I've been trying to use GROUP BY and also a subquery to try and get it but having no luck.
Can anyone help please? Thanks in advance
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…