0

我只需要数据,pbox.id<'".$pbid."' and cbox.id<'".$cbid."'但它不起作用。我尝试了很多东西仍然无法正常工作,它获取了所有数据。它看起来不像我的操作员。我如何解决这个问题?

SELECT DISTINCT pbox.id as pbid,
cbox.id as cbid,
box.upload_type,
box.id,
box.box_type,
box.page_name,
box.title,
box.connect,
box.type,
box.uid,
box.description,
box.image,
box.url,
box.status,
box.date,
box.time
FROM boxes as box
LEFT JOIN page_boxes as pbox on pbox.bid=box.id
JOIN page_subcribers as pages on pages.page_id=pbox.page_id 
LEFT JOIN category_boxes as cbox on cbox.bid=box.id 
LEFT JOIN subcribers as catsb on cbox.category_id=catsb.cid 
WHERE pages.uid='".$session_id."' or catsb.uid='".$session_id."' and box.status='".$approval."' and cbox.id<'".$cbid."' and pbox.id<'".$pbid."'
ORDER BY pbox.id desc,cbox.id DESC LIMIT 10
4

1 回答 1

2

尝试在 WHERE 子句上使用括号强制运算符优先级:-

SELECT DISTINCT pbox.id as pbid,
cbox.id as cbid,
box.upload_type,
box.id,
box.box_type,
box.page_name,
box.title,
box.connect,
box.type,
box.uid,
box.description,
box.image,
box.url,
box.status,
box.date,
box.time
FROM boxes as box
LEFT JOIN page_boxes as pbox on pbox.bid=box.id
JOIN page_subcribers as pages on pages.page_id=pbox.page_id 
LEFT JOIN category_boxes as cbox on cbox.bid=box.id 
LEFT JOIN subcribers as catsb on cbox.category_id=catsb.cid 
WHERE (pages.uid='".$session_id."' 
or catsb.uid='".$session_id."')
and box.status='".$approval."' 
and cbox.id<'".$cbid."' 
and pbox.id<'".$pbid."'
ORDER BY pbox.id desc,cbox.id DESC 
LIMIT 10
于 2013-11-08T18:50:09.823 回答