Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Abfrage mit doppeltem Ergebnis?

Drei Möglichkeiten, dies zu lösen (im Grunde haben Sie mehr als eine Zeile in nwork):

SELECT distinct b.id,b.body FROM btin b
INNER JOIN nwork n ON (n.mem_id = b.mem_id)  
WHERE b.parentid = '0'
AND ('401' IN (n.frd_id, b.mem_id))
ORDER BY b.date DESC 
LIMIT 20 OFFSET 0


SELECT  b.id,b.body 
FROM btin b
Where b.id in (SELECT  b.id FROM btin b  INNER JOIN nwork n ON (n.mem_id = b.mem_id)  
                WHERE b.parentid = '0' AND ('401' IN (n.frd_id, b.mem_id)))
ORDER BY b.date DESC 
LIMIT 20 OFFSET 0

SELECT  b.id,b.body FROM btin b
INNER JOIN nwork n ON (n.mem_id = b.mem_id)  
WHERE b.parentid = '0'
AND ('401' IN (n.frd_id, b.mem_id))
Group by b.id, b.body, b.date
ORDER BY b.date DESC 
LIMIT 20 OFFSET 0