select 客户号,姓名,性别,联系电话 from customers where 客户号 not in (select 客户号 from orders where year(签订日期)=2008 and month(签订日期)=2) order by 客户号 desc into table tableone
就本题来说,9楼和10都可以,
但9楼适用强,由于老师故意说2月,就意味着2月有29天和28天;但如果换了个日期条件,9楼就很容易变通,即
nYear=2009
nMonth=3
select 客户号,姓名,性别,联系电话 from customers where 客户号 not in (select 客户号 from orders where year(签订日期)=nYear and month(签订日期)=nMonth) order by 客户号 desc into table tableone
请问这样的题只能用 not in 吗?我是初学者,老师没有讲过not in的用法..请问还有其他的方法吗?
第1题逻辑最严谨的方法就是用子查询了:
SELECT 客户号,姓名,性别,联系电话 FROM Customers ;
WHERE 客户号 NOT IN ;
(SELECT 客户号 FROM Orders WHERE BETWEEN(签订日期,{^2008-02-01},{^2008-02-29})) ;
ORDER BY 客户号 DESC ;
INTO TABLE TableOne