我有垃圾邮件过滤器。请包含PHP在 主题行中确保我会收到你的消息。 select CarIndex FROM DealerCatalog, BigCatalog WHEREDealerCatalog.CarIndex<>BigCatalog.CarIndex Regards,Shawn--Shawn Wilson sh***@glassgiant.com http://www.glassgiant.com I have a spam filter. Please include "PHP" in thesubject line to ensure I''ll get your message. 在数据库手册中查找有关WHERE子句的部分。 在这种情况下,它足以扭转条件。 更一般你可以使用not in with子查询结构。 - http://home.mysth.be/~timvw 在数据库手册中查找有关WHERE子句的部分。 在这种情况下,它足以扭转条件。更一般的是你可以使用not in with子查询构造。 Lookup the section about the WHERE clause in your database manual. In this case it''s enough to reverse the condition. More general you might use the not in with subquery construct. 上面提到的建议肯定不会很快 - 当我将原始语句中的=更改为<>时,我不得不杀死a sql查询;如上所述建议 。这告诉我建议是错误的。 答案是使用LEFT JOIN - 任何没有加入的东西都会给出一个 NULL值,而且它是大型数据集的速度更快(我已经获得了12,000条记录): SELECT CarIndex FROM DealerCatalog LEFT JOIN BigCatalog ON DealerCatalog.CarIndex = BigCatalog.CarIndex WHERE BigCatalog.CarIndex IS NULL The suggestions mentioned above are certainly not speedy - I had to killa sql query when i changed the = in my original statement to <> assuggested above. Which tells me that the suggestions are wrong. The answer is to use LEFT JOIN - anything that doesn''t join is given aNULL value , and it''s a heck of a lot speedier of large datasets (i''vegot 12,000 records): SELECT CarIndex FROM DealerCatalog LEFT JOIN BigCatalog ONDealerCatalog.CarIndex=BigCatalog.CarIndex WHERE BigCatalog.CarIndex IS NULL 这篇关于mysql中的否定SELECT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-21 09:05