DELETE FROM `pre_forum_post` WHERE `dateline`<$time AND `first`=0 AND `authorid`<>(判斷不等于該條中的tid查出來本表內first=1那條的樓主authorid) LIMIT 999999
DELETE FROM `pre_forum_post` WHERE `dateline`<$time AND `first`=0 AND `authorid`<>(判斷不等于該條中的tid查出來本表內first=1那條的樓主authorid) LIMIT 999999
問下這句mysql同一個表內要同時判斷兩條資料該怎么寫,pid就是帖子的序號(唯一),它有個tid欄位表示屬于哪個主題帖,authorid就是發貼者,沒有樓主欄位必須根據first=1查出1樓的那條來獲取樓主的authorid判斷不等于,
洗掉時間$time之前的回復但樓主的除外 ,該怎么寫呢?
是PHP的new mysqli()鏈接的資料庫.
uj5u.com熱心網友回復:
DELETE FROM `pre_forum_post` a WHERE a.`dateline`<$time AND a.`first`<>1 AND a.`authorid`<>(SELECT b.`authorid` FROM `pre_forum_post` b WHERE b.`tid`=a.`tid` AND b.`first`=1) LIMIT 999999我這樣寫直接報語法錯誤喔
uj5u.com熱心網友回復:
DELETE a
FROM pre_forum_post a
WHERE a.dateline<$time AND a.first<>0
AND not exists (SELECT 1 FROM pre_forum_post b WHERE b.tid=a.tid and a.authorid = b.authorid AND b.first=1)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/103680.html
標籤:MySQL
上一篇:求請教FOXPRO的問題
