我有一個像選擇是否cl.t_sc_1 = 1或cl.t_sc_2 = 1或cl.t_sc_3 = 1分AND列1 = 10
SELECT DISTINCT SQL_CALC_FOUND_ROWS cl.id AS id,
cl.column1 AS column1,
cl.column2 AS column2,
cl.column3 AS column3,
cl.t_sc_1 AS t_sc_1,
cl.t_sc_2 AS t_sc_2,
cl.t_sc_3 AS t_sc_3
FROM classifieds AS cl
WHERE (cl.t_sc_1 = 1 OR cl.t_sc_2 = 1 OR cl.t_sc_3 = 1)
AND column1 = 10 AND column2=10 AND column3=10
ORDER BY cl.id ASC
而且我想要得到結果的查詢是否(t_sc_1 = 1或t_sc_2 = 1 OR t_sc_3 = 1)OR the_three_columns = 1 AND column1 = 10 etc,...我得到resluts,其中t_sc_1 = 1,t_sc_2 = 1,t_sc_3 = 1,column1 = 10等。 因此,只有t_sc_1 = 1的行或者只有column3 = 1的行纔會顯示在結果中。
真正的查詢是動態的,有時'OR'部分包含兩個cl.t_sc_1 = 1(例如(cl.t_sc_1 = 1或cl.t_sc_2 = 1))有時包含三個例子。
我知道子句是否不存在,但有沒有辦法實現這一點?
感謝您的幫助
提供您的CODE –