我在状态3和状态1中收到了相同的电子邮件。我只需要显示状态3的电子邮件,这个查询是在状态3的页面中显示我,也是状态1的电子邮件
下面是我的问题:
SELECT live_customers.Id, live_customers.date,
live_customers.firstname, live_customers.lastname, live_customers.phone,
live_customers.phone2, live_customers.email, live_customers.num_sellers,
live_customers.sell_date,live_customers.public_description,
live_customers.public_image, live_customers.price,
live_customers.takanon, live_customers.confirm_mail_sent, live_customers.paid,
live_customers.shirt_size, live_customers.shirt_size_extra,
live_customers.stand_rent, live_customers.refunded, live_customers.call1,
live_customers.call2, live_customers.notes,
live_customers.auth_number, live_customers.hasContact, live_customers.IP,
live_customers.status, live_status.name AS StatusName,
live_status.color AS StatusColor, live_compound.name AS CompoundName
FROM live_customers
INNER JOIN live_status
ON live_status.Id=live_customers.status
INNER JOIN
LEFT JOIN live_compound
ON live_compound.Id=live_customers.compound_id
WHERE live_customers.status='3'
GROUP BY
live_customers.Id
ORDER BY
live_customers.Id DESC
LIMIT 0,30
发布于 2014-03-06 16:59:19
您已经混合了内连接和左连接...
尝尝这个
SELECT live_customers.Id, live_customers.date,
live_customers.firstname, live_customers.lastname, live_customers.phone,
live_customers.phone2, live_customers.email, live_customers.num_sellers,
live_customers.sell_date,live_customers.public_description,
live_customers.public_image, live_customers.price,
live_customers.takanon, live_customers.confirm_mail_sent, live_customers.paid,
live_customers.shirt_size, live_customers.shirt_size_extra,
live_customers.stand_rent, live_customers.refunded, live_customers.call1,
live_customers.call2, live_customers.notes,
live_customers.auth_number, live_customers.hasContact, live_customers.IP,
live_customers.status, live_status.name AS StatusName,
live_status.color AS StatusColor, live_compound.name AS CompoundName
FROM live_customers
INNER JOIN live_status
ON live_status.Id=live_customers.status
INNER JOIN live_compound
ON live_compound.Id=live_customers.compound_id
WHERE live_customers.status='3'
GROUP BY
live_customers.Id
ORDER BY
live_customers.Id DESC
LIMIT 0,30
发布于 2014-03-06 19:12:46
我找到了我问题的解决方案。这就是了。希望这能对某些人有所帮助
SELECT live_customers.Id, live_customers.date,
live_customers.firstname, live_customers.lastname, live_customers.phone,
live_customers.phone2, live_customers.email, live_customers.num_sellers,
live_customers.sell_date,live_customers.public_description,
live_customers.public_image, live_customers.price,
live_customers.takanon, live_customers.confirm_mail_sent, live_customers.paid,
live_customers.shirt_size, live_customers.shirt_size_extra,
live_customers.stand_rent, live_customers.refunded, live_customers.call1,
live_customers.call2, live_customers.notes,
live_customers.auth_number, live_customers.hasContact, live_customers.IP,
live_customers.status, live_status.name AS StatusName,
live_status.color AS StatusColor, live_compound.name AS CompoundName
FROM live_customers
INNER JOIN live_status
ON live_status.Id=live_customers.status
INNER JOIN live_compound
ON live_compound.Id=live_customers.compound_id
WHERE live_customers.status='3'
AND live_customers.Email NOT IN (SELECT Email FROM live_customers WHERE status=1)
GROUP BY
live_customers.Id
ORDER BY
live_customers.Id DESC
https://stackoverflow.com/questions/22219390
复制相似问题