欧美一区二区三区性视频_婷婷综合另类小说色区_亚洲av乱码一区二区三区林ゆな_天堂在线资源中文在线8_久久这里只有精品首页

妙網(wǎng)科技 妙網(wǎng)科技 首頁 妙網(wǎng)科技 網(wǎng)站開發(fā) 妙網(wǎng)科技 php SQL語句有and也有or應(yīng)該怎么寫?

php SQL語句有and也有or應(yīng)該怎么寫?

所屬欄目: 網(wǎng)站開發(fā) | 更新時間:2016-8-14 | 閱讀:3686 次
用小括號()包含就可以區(qū)別開。
例如:
select * from table where title like '%hello%' and (contents like '%good%' or contents like '%ok%')
sql語句where部分解釋如下:
title like '%hello%' and (contents like '%good%' or contents like '%ok%')
title 字段模糊查詢包含 hello 字符串的數(shù)據(jù),并且 contents 字段模糊查詢包含 good 字符串的數(shù)據(jù),或者contents 字段模糊查詢包含 ok 字符串的數(shù)據(jù)
比如數(shù)據(jù)表數(shù)據(jù)如下:
字段 id --- title --- contents
數(shù)據(jù) 1 --- 11hello22 --- yougoodss
2 --- aaahello333 --- fdffokssfff
3 --- bbbhello666 ---- fffaafdafa1
像上面的數(shù)據(jù)sql語句會同時查詢出1、2的數(shù)據(jù)。
就像四則運算加上小括號就有了計算優(yōu)先原則。 
?