-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 09 February 2004 08:05, Carl Schéle, IT, Posten wrote: > I use php 4.1.1. mysql 3.23.49 and phpmyadmin 2.5.4 > > I have two tables > > classes > ------------ > - class_id (int) > - class_name (text) > ---------------------------- > HS > HD > DD > DS > MD > > champions > ---------------- > - champions_id (int) > - year (text) > - class_name (text) > - winner (text) > ---------------------------- > 1981 HS PETER > 1981 DS ANNE > > What I want to do is to list all class_name from classes that aren't > represented a specific year. > > So what I want as result is HD, DD, MD > I'm trying to use the following query: > > SELECT class_name FROM classes WHERE NOT EXISTS (SELECT * FROM champions > WHERE champions.class_name=classes.class_name AND champions.year='1981') > > ERRORREPORT: > #1064 - You have an error in your SQL syntax. Check the manual that > corresponds to your MySQL server version for the right syntax to use near > 'EXISTS ( > > Someday please help me. Am I not using the right version of php? Or is it > mysql?
The problem is that subselects aren't supported in 3.23 of MySQL. Try the following query: Select cl.class_name from classes cl left join champions ch on cl.class_name = ch.class_name where ch.class_name is null; -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQFAJ5pWjeziQOokQnARAuWaAJ9rYuMSD9fm62FdC45k9utKElVJhACePdhN pqJAXScklcXHI9zJSY/L1Wg= =AYsU -----END PGP SIGNATURE----- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]