[SQL] Dubelle records met join

Pagina: 1
Acties:
  • 29 views sinds 30-01-2008

Acties:
  • 0 Henk 'm!

  • Yohost!
  • Registratie: Juni 2000
  • Laatst online: 15-09 19:58
Ik heb 2 tabellen: Topics en Posts:

Afbeeldingslocatie: http://vos.homeip.net/~jelmer/relatie.jpg

Nou wil ik alle topics gesorteerd op Posts.LastReply. Alleen mogen er geen dubbele topics in zitten. Verder is het wel makkelijk als ik gewoon bij alle kolommen kan van deze 2 tabellen.

Hoe doe ik dit met SQL?

Alvast bedankt. :)

Acties:
  • 0 Henk 'm!

  • Feyd-Rautha
  • Registratie: November 2001
  • Laatst online: 02-08 23:34
een goed boek kopen over SQL en u bezighouden met het te beginnen studeren ...

edit: als je het op de gemakzuchtige manier wilt doen, kun je access ook altijd een SQL statement laten genereren. Om te weten hoe je dat moet doen, moet je een goed boek kopen over Access en u bezighouden met het te beginnen studeren :P :Y) 8-)

I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. Where the fear has gone there will be nothing. Only I will remain.


Acties:
  • 0 Henk 'm!

  • Dennis
  • Registratie: Februari 2001
  • Nu online
SELECT DISTINCT

Acties:
  • 0 Henk 'm!

  • Yohost!
  • Registratie: Juni 2000
  • Laatst online: 15-09 19:58
Op woensdag 12 juni 2002 15:02 schreef ddc het volgende:
SELECT DISTINCT
Werkt niet, omdat de Posts.LastReply altijd anders is. DISTINCT haalt volgens mij alleen de dubbele records eruit.

Acties:
  • 0 Henk 'm!

  • whoami
  • Registratie: December 2000
  • Laatst online: 11:59
Basiskennis SQL:
code:
1
2
3
4
select  topics.title, max(reply.lastreply)
from topics, reply
where topics.topicid = reply.topicid
group by topics.title

Oftewel: zie -Avalanche-, koop een boekie.

https://fgheysels.github.io/


Dit topic is gesloten.