SQL语句

上一篇 / 下一篇  2017-11-23 16:12:49

查找:select* from table1 where 范围
like查找:select * from table1 where field1 like '%value%'
select * from table2 where field2 like '1234%'
插入:insert into table1 (field1,field2)value(value1,value2)
删除:delete from table1 where 范围
更新:update table1 set field1 = value1 where 范围

排序:select * from table1 order by field1,field2 [desc]
总数: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

举例:
1.user表中,表字段为:name、email、password、loginTime;
SQL:查询user表中用户名含有“测试”,并返回最近登录的前10条记录
select* from user where name like '%测试%' order by loginTime desc limit 10;

2.找到pay库card表中的银行卡号bin_code开头为622848的卡;
select * from pay.'card_bin'a where a.bin_code like '622848%';






TAG: SQL sql

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2019-06-18  
      1
2345678
9101112131415
16171819202122
23242526272829
30      

数据统计

  • 访问量: 3228
  • 日志数: 11
  • 建立时间: 2017-10-12
  • 更新时间: 2018-03-01

RSS订阅

Open Toolbar