Thread die letzten 2 Ergebnisse in einer Ergebniszeile (4 answers)
Opened by pktm at 2009-11-09 14:47

pktm
 2010-04-17 12:02
#136197 #136197
User since
2003-08-07
2921 Artikel
BenutzerIn
[Homepage]
user image
Ok, ich habe es mal so gemacht:
Code: (dl )
1
2
3
4
5
6
SELECT w.word_id, w.word,
(SELECT frequeny FROM analyses a WHERE a.word_id = w.word_id ORDER BY `date` DESC LIMIT 1) as cpos,
(SELECT `date` FROM analyses a WHERE a.word_id = w.word_id ORDER BY `date` DESC LIMIT 1) as cdate,
(SELECT frequeny FROM analyses a WHERE a.word_id = w.word_id ORDER BY `date` DESC LIMIT 1,1) as ppos,
(SELECT `date` FROM analyses a WHERE a.word_id = w.word_id ORDER BY `date` DESC LIMIT 1,1) as pdate
FROM words w


Geht das nicht auch besser?
Ich habe mal versucht, JOIN zu verwenden, aber das Problem dabei ist, dass sich dann das LIMIT nicht mehr nur auf die relativierte Tabelle analyses bezieht, sondern auf die gesamte Abfrage.
Last edited: 2010-04-17 16:24:02 +0200 (CEST)
http://www.intergastro-service.de (mein erstes CMS :) )

View full thread die letzten 2 Ergebnisse in einer Ergebniszeile