請問怎么對所有列進行查詢select * from bookSystem where author LIKE '%".$_POST['search']."%'我這個是對author列的,可以對所有列嗎比如我還有where bookNamewhere press等等,所有列
4 回答

慕尼黑8549860
TA貢獻1818條經驗 獲得超11個贊
一、
1)針對author這個字段中含有POST內容的所有列:select * from bookSystem where author LIKE '%".$_POST['search']."%'
2)針對bookName 這個字段中含有POST內容的所有列:
select * from bookSystem where bookName LIKE '%".$_POST['search']."%'
3)針對press 這個字段中含有POST內容的所有列:
select * from bookSystem where press LIKE '%".$_POST['search']."%'
二、WHERE 子句
1)如需有條件地從表中選取數據,可將 WHERE 子句添加到 SELECT 語句。
2)語法SELECT 列名稱 FROM 表名稱 WHERE 列 運算符 值

揚帆大魚
TA貢獻1799條經驗 獲得超9個贊
針對不同的列,可以用and連接起來。
類似:select * from bookSystem where author LIKE '%".$_POST['search']."%' and bookName LIKE '%".$_POST['bookName']."%' and press LIKE '%".$_POST['press']."%' ,如果用and的話三個條件必須都要滿足才可以,如果只是其中一個的話用or就可以。

HUX布斯
TA貢獻1876條經驗 獲得超6個贊
可以用'and'啊 select * from bookSystem where author LIKE '%"xxxxxxx"% ' and bookName LIKE '%"xxxxxxxx"%‘ 用and連接就是滿足多個條件
添加回答
舉報
0/150
提交
取消