我有一個表,看起來像這樣根據條件對多行
Tag_Id Bid Category Title
1 1 Toys Ludo
2 1 Toys Snakes
3 2 Food Potato
4 1 Food Chicken
5 1 Name Chris
6 2 Name Joe
我想寫基於以下條件其中發現投標查詢選擇IDS。
Find Bid's where
(
(Category = "Toys" AND Title = "Ludo")
OR
(Category = "Toys" AND Title = "Snakes")
)
AND (Category = "Food" AND Title = "Potato")
AND
(
(Category = "Name" AND Title = "Chris")
OR
(Category = "Name" AND Title = "Joe")
)
請注意,在不同類別之間存在相同類別和AND之間的OR。有沒有辦法通過單個查詢來實現這一點?
可以b'MySQL的case'聲明幫助ü :http://dev.mysql.com/doc/refman/5.0/en/case-statement.html – diEcho 2011-04-14 06:58:06
您能描述上述示例數據所需的預期輸出嗎? – Dheer 2011-04-14 07:25:39
預期的輸出是競標1 – Ankit 2011-04-14 07:38:43