数据基本查询

—数据查询 —查询返回的结果通常叫做记录集或者结果集(RecordSet) –注: –使用sql2000自带数据库pubs的authors表测试––1、查询表中的全部数据 select * from authors–2、查询部分的行和列——条件查询 select au_lname, phone from authors where au_id = ‘267-41-2394′–3、在查询中给列其别名 select au_lname as 作者姓名, phone as 作者电话 from authors where au_id = ‘267-41-2394′ –注: –1、给列起别名要使用as,as可以省略,建议不要省略 –2、起的列名建议不要加引号,加引号以后可能出现编码等问题 –3、既然列可以起别名,那么表也可以起别名,用法和给列起别名一样,使用as,as也可以省略 –4、也可以使用“=”给列起别名,即:作者姓名 = au_lname, 作者电话 = phone,效果同as一样–4、查询某一列的值为空 select au_fname + ‘.’ + au_lname from authors where address is null –注: –1、where条件使用要用is null–5、返回固定的行数 select top 3 au_fname, address from authors where contract = 0 –注: –1、返回固定行数使用关键字top加上行数就可以了–6、返回百分之多少行 select top 2 percent au_fname, [...]
posted @ 2008-11-12 10:15  大鹏ME  阅读(211)  评论(0编辑  收藏  举报