常用sql语句大全
sql基本语句有哪些?
sql基本语句有哪些?
查询语句-select * from table select * from table where 条件1=数值 and 条件2=数值 select * from table where id in (select id from table)两表关联 select a.a,b.b,c.c from table1 a,table2 b,table3 c where a.id1=b.id2插入语句-insert into table (字段1,字段2,字段3,……) values (数值1,数值2,数值3,……)更新语句-update 表名 set 数值 where=id = 1添加列语句-alter table 表名 add (列名1 类型1,列名2 类型2,列名3 类型3,……)修改列类型-alter table 表名 modify (列名1 类型1,列名2 类型2,列名3 类型3,……)删除列语句-alter table 表名 drop column 列名s显示查询时间-set timing on删除表语句-deltet table 表名清空表数据-truncate table 表名修改列名 - ALTER TABLE emp RENAME COLUMN comm TO newa
sql查询语句大全及实例?
(1)数据记录筛选:
sql=#34select * from 数据表 where 字段名=字段值 orderby 字段名 [desc] #34
sql=#34select * from 数据表 where 字段名 like #39\%字段值\%#39 orderby 字段名 [desc]#34
sql=#34select top10 * from 数据表 where 字段名 orderby 字段名[desc]#34
sql=#34select * from 数据表 where 字段名 in(#39值1#39,#39值2#39,#39值3#39)#34
sql=#34select * from 数据表 where 字段名 between 值1 and 值 2#34
(2)更新数据记录:
sql=#34update 数据表 set 字段名=字段值 where 条件表达式#34
sql=#34update 数据表 set 字段1=值1,字段2=值2……字段n=值n where 条件表达式#34
(3)删除数据记录:
sql=#34delete from 数据表 where 条件表达式#34
sql=#34delete from 数据表 #34(将数据表所有记录删除)