Re: Single occurance of data

From: Date: Tue, 26 Nov 2002 19:57:02 +0000
Subject: Re: Single occurance of data
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-23681@lists.php.net to get a copy of this message
Alex, > I have two tables in my database with a department name. > One table (department), the name only appears once and it includes all > departments in the school. In the other table, (courses) department can > appear several times, but not all departments will be in the table. > > I used the following code to try to get the names of the departments from > the courses table, but unfortunately I get all occurences of the department. > Can someone help me get ony one occurrence of each department from the > courses table. > > $query = "select departments.department, courses.department from > departments, courses where departments.department=courses.department"; > $result = mysql_query($query); Check out MySQL's DISTINCT modifier. Regards, =dn

« previous php.db (#23681) next »