我有如下表:SQL請求 - 多值
userid title content
1 gender male
1 location NY
2 gender female
2 location SF
3 gender female
3 location NY
我試圖用性別=「男」和位置=「NY」
,如果我嘗試僅檢索用戶ID :
select userid
from table
where content="male"
AND location="NY";
它將返回null。 任何想法如何做到這一點?
順便說一句:這是一個表結構的壞主意。如果可能,我會建議重新構建它。 – JohnFx
我知道,但它是這樣設計的。 – user7330
我知道用遺留代碼卡住是什麼感覺。 –