Everyone has his/her own driving license, and I need to know what kind of person (client or user) is.
mysql> select userID, clientID from client, user where (clientCodeDrivingLicense= 321321321 || userCodeDrivingLicense = 321321321); +--------+-------+ | userID | clientID | +--------+-------+ | 1 | 2 | | 2 | 2 | | 3 | 2 | | 4 | 2 | | 5 | 2 | +--------+-------+ 5 rows in set (0.00 sec) But, what I want is something like that: +--------+-------+ | userID | clientID | +--------+-------+ | Null | 2 | +--------+-------+ I tried something like this: select COUNT(DISTINCT u.userID), userID, clientID from client, user where (clientCodeDrivingLicense = 321321321 || userCodeDrivingLicense = 321321321); +--------------------------+--------+-------+ | COUNT(DISTINCT u.userID) | userID | clientID | +--------------------------+--------+-------+ | 5 | 1 | 2 | +--------------------------+--------+-------+ 1 row in set (0.00 sec) But it wont be efficient enough in the future. I suppose my solution is an Join, but they have no intersection, so, I cant imagine how do it Thank you!! Regards Rocío Gómez Escribano <mailto:r.sanc...@ingenia-soluciones.com> r.go...@ingenia-soluciones.com Descripción: cid:image002.jpg@01CB8CB6.ADEBA830 Polígono Campollano C/F, nº21T 02007 Albacete (España) Tlf:967-504-513 Fax: 967-504-513 www.ingenia-soluciones.com