我有两个表:
client
:(backoffice_users_id,idfile,validation_file)
transmission
:(backoffice_users_id,idfile,nbr_files)
我想向具有最少文件数且validation_file=1的客户展示
我做了这样的事情,它给了我最小数量但是validation_file = 0而不是validation_file = 1,有人可以帮我吗?
SELECT `transmission`.*
FROM `transmission`
INNER JOIN `client`
ON client.backoffice_users_id=transmission.backoffice_users_id
WHERE (transmission.idfile='2')
AND (client.validation_file<>0)
AND (transmission.nbr_files=(
SELECT min(nbr_files)
FROM transmission
WHERE transmission.idfile='2'))
GROUP BY `client`.`backoffice_users_id`
LIMIT 1