虽然 SELECT 语句的完整语法较复杂,但是其主要的子句可归纳如下:
SELECT select_list
[ INTO new_table ]
FROM table_source
[ WHERE search_condition ]
[ GROUP BY group_by_expression ]
[ HAVING search_condition ]
[ ORDER BY order_expression [ ASC | DESC ] ]
可以在查询之间使用 UNION 运算符,以将查询的结果组合成单个结果集。
也就是说,order by放在最后面。
我实践过的那些sql语句
access: SELECT * FROM (select * from AllStudent where quyu like "*绍兴*") where id >4000;
asp:"select zhiye,count(zhiye) as total from Allstudent group by zhiye"
asp: sql="select count(id) as total from Allstudent where datediff('yyyy',birthday,now)>="&startAge&" and datediff('yyyy',birthday,now)<"&endAge