我想做一個中西藥查詢系統
它有中藥和西藥兩個欄位
它現在的問題是
如何在我輸入資料後
先執行判斷
判斷中藥是否為空,西藥是否為空,或兩者不為空
再執行查詢
謝謝大家的幫忙!!
這是我寫的語法..但不能用...會出現錯誤
if ('coldrug' == null){ SELECT *
FROM medicine
WHERE TCMCName = 'colherb' UNION SELECT * FROM medicine WHERE TCMEName = 'colherb' UNION SELECT * FROM medicine WHERE TCMGName = 'colherb';}
elseif('colherb' == null){ SELECT * FROM medicine WHERE `Western Medicine` = 'coldrug';}
else{ SELECT * FROM medicine WHERE TCMCName in ('colherb') and `Western Medicine` in ('coldrug') UNION SELECT * FROM medicine WHERE TCMEName in ('colherb') and `Western Medicine` in ('coldrug') UNION SELECT * FROM medicine WHERE TCMGName in ('colherb') and `Western Medicine` in ('coldrug');}
查看全部回復
我也來說兩句