现在的位置: 首页 > 数据库 > 正文

sql语句学习

2019年03月09日 数据库 ⁄ 共 2850字 ⁄ 字号 评论关闭

秒速赛车公式 www.l19l7.cn update

1、set一个字段
在表t_test中设置第二条记录(bs为2)的password为'***'。
update t_test t
?? set t.password = '***'
where t.bs = 2;

//lavasoft.blog.51cto.com/62575/27692

?

login

mysql -h 11.11.11.1 -u root -p

mysql -u root -p

view table field?

desc tablename

mysql> select host,user from mysql.user;
+-----------+-------------+
| host      | user        |
+-----------+-------------+
| %         | fishadmin   |
| %         | jiraadmin   |
| %         | root        |
| %         | udanceadmin |
| localhost | fishadmin   |
| localhost | jiraadmin   |
| localhost | jirauser    |
| localhost | root        |
+-----------+-------------+
8 rows in set (0.00 sec)

%意思任意主机都可以连接

android Sqlite

--update message set readstatus = 1 where sender = 13455556669 and receiver = 13455556667 and readstatus = 0;

--select * from message where readstatus <> 0;//readstatus不等于0的数据

--select * from message where sender='13455556661' and receiver='13455556663' and process=103 order by _id desc;
--select * from message limit 3;--只查询前三条数据
--select * from message limit 2,1;--指定偏移量和查询数据条数
select count(1) from message;--查询消息表中的数据条数


2.数据库查询语句
select * from message order by _id asc;按_id的升序
select * from message order by _id desc;按_id的降序
2.1
select sender,receiver,content from message group by sender order by _id desc;
当order by和group by一起使用的时候,要先用group by,再用order by


4.关于删除
从message表中删除_id=2的一条记录的SQL语句:
delete from message where _id = '2';
参考://blog.sina.com.cn/s/blog_69092aea0101879o.html
--select * from message order by _id desc;
--select * from message where sender = 'hello1' and receiver = 'hello2' or sender = 'hello2' and receiver = 'hello1';
--select * from message where sender = 'hello2' and receiver = 'hello1';
--CREATE TABLE IF NOT EXISTS temporder(_id INTEGER PRIMARY KEY AUTOINCREMENT, ordernumber text, ordertime text, appointtime text, appointstatus text, stationname text, serviceitem text,saname text, telephone text, rating text, commentcount text, isAuth INTEGER,
carbrand text, carkind text, carnum text, carage text, carmiles text, worktime text, price text, shoplongi text, shoplati text);
--CREATE TABLE IF NOT EXISTS ordera (_id INTEGER PRIMARY KEY AUTOINCREMENT, ok text);
--select _id, appointstatus, appointtime, ordernumber, stationname, serviceitem, saname, telephone from repairorder where telephone=13566667777;

--delete from message where _id = '2';

--CREATE TABLE IF NOT EXISTS carinfo (_id INTEGER PRIMARY KEY AUTOINCREMENT, carLogo INTEGER, carNum TEXT, carBrand TEXT, carLevel TEXT, carYear TEXT, phone TEXT);
--delete from message;
--select content from message where _id < 50 order by _id asc;
--select * from message group by sender;-- where readstatus = 0
--select * from message where receiver = 13455557777;
--update message set readstatus = 0 ;--where sender = 13455556667 and receiver = 13455557777;
--select * from message where readstatus=1 group by sender;
--delete from friendrequest;
--update friendrequest set agree=10 where reqfrom='13455556664' and reqto='13455556665';
--update friendrequest set agree = 13,icon='abc',added=32 where reqfrom= '13455556664' and reqto= '13455556665';
--select content from message;
--select _id from carinfo;
--update carinfo set carid = 110 where _id=12;
--delete from message;
--create table friends (username TEXT);
delete from friends where username = '13455556668' and jid='[email protected]';??

抱歉!评论已关闭.

  • 新疆各族群众体验端午传统文化 2019-05-25
  • 【十九大·理论新视野】动漫:“社会主义现代化强国”如何建成 2019-05-25
  • 太原黑臭水体治理接受国家专项督查 2019-05-24
  • 白芦笋:一年一会矜贵食 2019-05-24
  • 安徽通报2018年上半年全省旅游投诉情况 2019-05-24
  • 女性之声——全国妇联 2019-05-23
  • 【新华微视评】偏远农村的“智慧消防” 2019-05-23
  • 万花瞳:万花迷人眼 慧瞳观天下 2019-05-23
  • 视频:热心球迷!陈奕迅吴秀波惊现世界杯开幕式现场 2019-05-22
  • 【北京神龙京津车型报价】北京神龙京津4S店车型价格 2019-05-22
  • 国外看中国科技:中国隧道技术发展迅速享誉世界 2019-05-22
  • 孕妇在巴黎大区快线列车上产子 宝宝获赠“大礼” 2019-05-22
  • 【学习时刻】中国人民大学副校长刘元春:中央经济工作会议的四大亮点 2019-05-21
  • 环球佳酿举行新品发布会 百余款酒品集中发售 2019-05-21
  • 改造后的老旧楼房抗震能力是否提高?新老建筑是否共用逃生通道? 2019-05-21
  • 494| 786| 563| 602| 372| 111| 574| 639| 167| 231|