几个简单的基本的sql
语句 选择:select * from table1 where
范围 插入:insert into table1(field1,field2) values(value1,value2) 删除:delete from table1 where 范围 更新:update table1 set field1=value1 where 范围 查找:select * from table1 where field1 like ’%value1%’ (所有包含‘value1’这个模式的字符串)---like的语法很精妙,查资料! 排序:select * from table1 order by field1,field2 [desc] 分组:select * from table1 group by field1 ORDER BY count(ShopId) LIMIT 20 (兼并排序分页) 总数:select count(*) as totalcount from table1 求和:select sum(field1) as sumvalue from table1 平均:select avg(field1) as avgvalue from table1 最大:select max(field1) as maxvalue from table1 最小:select min(field1) as minvalue from table1[separator] 查询去除重复值:select distinct * from table1 使用外连接 A、left outer join: 左外连接(左连接):结果集既包括连接表的匹配行,也包括左连接表的所有行。 SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c B:right outer join: 右外连接(右连接):结果集既包括连接表的匹配连接行,也包括右连接表的所有行。 C:full outer join: 全外连接:不仅包括符号连接表的匹配行,还包括两个连接表中的所有记录。
麻烦采纳,谢谢!
select c_name,s_no,s_name from class,stu
where c_id = s_cid and c_stu>20 and sno like '[^not null]006%'
order by s_no desc
[^not null] 与--写法不同但含义 应该是相同的
评论列表(0条)