我有一個問題,用IN鍵運行查詢返回空。這是我的查詢:帶IN的MySQL查詢返回空
SELECT * FROM `sc_miscellaneous` where discount_for=4 AND stud_id IN (1,2) AND status=1
此查詢返回正確的結果。但如果我使用IN (2,3)
或IN (2)
意味着零結果。例如。
SELECT * FROM `sc_miscellaneous` where discount_for=4 AND stud_id IN (2,3) AND status=1
表sc_miscellaneous:
ID Miscellaneous misc_amount discount discount_for class stud_id status
1 5 200 2 4 1 1,2,3,4,5,6, 1
7,8,9,10,11,
12,13,14,15,16,
17,18,19
2 6 500 2 4 1 1,2,3,4,5,6,7 1
先謝謝了。
stud_id是什麼類型? –
參考[this](http://stackoverflow.com/questions/10480568/comma-separated-values-in-mysql-in-clause)或[this](http://dba.stackexchange.com/questions/52492/mysql-using-comma-separated-values) –