Re: SELECT giving too much :)

From: Date: Thu, 30 Aug 2001 14:16:54 +0000
Subject: Re: SELECT giving too much :)
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-11988@lists.php.net to get a copy of this message
SELECT distinct(students.fname), courses.title AS course FROM students, courses, > course_enrolments, groups, locations, staff WHERE > (students.studentID=course_enrolments.studentID AND > course_enrolments.courseID=courses.courseID) AND > (students.groupID=groups.groupID) AND (staff.staffID=courses.staffID) ORDER > BY fname ASC should do iy Steve "Beau Lebens" <B.Lebens@curtin.edu.au> wrote in message news:A2B098B4E624D511BED900508BB92A57E2522B@exmsb02.curtin.edu.au... > Hi guys, I have a set-up to query a database by allowing the user to build a > query from selecting fields, restrictions etc etc. > > It produces the following; > > SELECT students.fname, courses.title AS course FROM students, courses, > course_enrolments, groups, locations, staff WHERE > (students.studentID=course_enrolments.studentID AND > course_enrolments.courseID=courses.courseID) AND > (students.groupID=groups.groupID) AND (staff.staffID=courses.staffID) ORDER > BY fname ASC > > which gets the right results, but it returns something like this; > > +-------+------------------------------------------------------+ > | fname | course | > +-------+------------------------------------------------------+ > | Beau | Graduate Certificate in Learning Technologies (K-12) | > | Beau | Graduate Certificate in Learning Technologies (K-12) | > | Grant | Short Course in Learning Technologies (K-12) | > | Grant | Short Course in Learning Technologies (K-12) | > +-------+------------------------------------------------------+ > > and it should only be returning one of each of those records.... any > suggestions? > > thanks > > Beau > > > -- > Beau F Lebens, Technical Officer > National Key Centre for School Science and Mathematics > Science and Mathematics Education Centre > Curtin University of Technology, > GPO Box U1987 Perth, Western Australia 6845 > > t: +61 8 9266 7297 (has voice-mail) > f: +61 8 9266-2503 (ATT: Beau Lebens) > e: b.lebens@curtin.edu.au > w: http://learnt.smec.curtin.edu.au/

« previous php.db (#11988) next »