字體:  

判斷輸出值再套用其對應查詢(php5+mysql5)

h055971328 發表於: 2009-7-17 10:35 來源: ADJ網路控股集團


不好意思我在做一個中西藥交互作用查詢系統
我有設定2個查詢欄位(中藥)和(西藥)
目前我已經分別寫出2種查詢語法
當中藥或西藥欄位一者為空
SELECT *
FROM medicine
WHERE TCMCName = 'colherb' OR TCMEName = 'colherb' OR TCMGName = 'colherb'  UNION SELECT * FROM medicine WHERE `Western Medicine` = 'coldrug'
當中藥和西藥欄位都有值(交叉查詢)
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')
我該如何在輸出值後先判斷中藥或西藥是否有空值
再將其導入適用的查詢語法呢?
謝謝大家的指導^^