我的查詢看起來像如何使用避免擴展值的MySql Query來搜索確切的字符串?
$search_query = db_query("SELECT nd.nid, users.name, nd.type FROM node as nd
LEFT JOIN node_revisions as nd_rev ON nd_rev.nid = nd.nid AND nd_rev.vid = nd.vid
LEFT JOIN users ON nd.uid = users.uid
WHERE nd.status = 1 AND nd_rev.body LIKE LOWER('%node/100%')
AND nd.nid NOT IN(SELECT DISTINCT nid FROM term_node WHERE tid = 293)");
該查詢實際上是從node_revisions.body領域,其中包括 節點/ 1000節點/ 1001 ....等等,
我想返回所有的比賽得到的只是儘可能地像
"node/100"
"node/100/"
"/node/100"
"/node/100/"
'node/100'
'node/100/'
'/node/100'
'/node/100/'
和不喜歡精確匹配的結果
"node/1006"
"node/10064/"
"/node/1000"
"/node/10001/"
'node/10023'
'node/1005/'
'/node/1001'
'/node/10069/'
這上面的查詢返回的結果我擁有串像下面.. ..A HREF =「/節點/ 1006」
如何避免這種錯誤呢?請幫助..
我的一個節點具有ID 1666具有串一些事情,如」 ..information,請參閱 ...「。 QUERY:SELECT nd.nid,users.name,nd.type FROM node as nd LEFT JOIN node_revisions as nd_rev ON nd_rev.nid = nd.nid AND nd_rev AND nd_rev .vid = nd.vid LEFT JOIN users ON nd.uid = users.uid WHERE nd.status = 1 AND nd_rev.body REGEXP「^ /?node/1006 /?$」 – Pasu