Page 1 of 1

two id's working together..?

Posted: Mon Sep 27, 2004 10:16 am
by keffo
Hmm.. Im stuck. Cant think it logic..

Hey.

Im re-writing some of this script, hmm. the first is, that.. I have one table for the results and one for the claninfo.

Results & Clans.

In Clans i use cid instead of Results id, but the thing is. when you check teh report i want the right clan (cid?) to fit with the result.

do you get it? how do i do? :> Ive written a add script and so, and it works fine.. now i need to know how to get the right clan info into the "report" stuff.

Cheers

Posted: Wed Oct 06, 2004 11:01 pm
by tyldis
Not sure I follow you, but I think you might want to read up on joins.

Example tables (underline denotes primary key):
clans(ClanID,ClanName,ClanWebsite)
results(MatchID,ClanID,ScoreUs,ScoreThem)

Example SQL:
SELECT * FROM results LEFT JOIN clans ON results.ClanID = clan.ClanID;

That should match the clan with the match.

Untested code at 6 AM!

Edit: And lo and behold an obvious error spotted and corrected.

Posted: Thu Oct 07, 2004 12:38 am
by iler
Or just like this.

SELECT * FROM results, clans WHERE results.ClanID = clan.ClanID, ORDER BY MatchID DESC;