分開查詢spa
先查詢idstring
select CAST(group_concat(ids) AS CHAR(10000) CHARACTER SET utf8) as iid it
from (select SUBSTRING_INDEX(group_concat(id ORDER BY 字段),',',4) as ids from `table` group by 字段) as valtable
在根據id查詢數據select
SELECT * FROM table where id in ($id)數據
這種也是能夠的查詢
select 字段,substring_index(group_concat( concat(字段,':',字段) order by 字段 desc separator '|'),'|',5) from table group by 字段;tab
具體看狀況co
DELETE FROM xxx WHERE id NOT IN(SELECT id FROM (SELECT MAX(b.id) AS id FROM xxx b GROUP BY b.xxxx) b)background