如何使用sql语句

发布时间:2022-01-15 09:36:25 作者:小新
来源:亿速云 阅读:148

这篇文章给大家分享的是有关如何使用sql语句的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

update

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

http://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';
参考:http://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='13455557777@iz280uotbvjz';

感谢各位的阅读!关于“如何使用sql语句”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

推荐阅读:
  1. MySQL常用SQL语句及使用实例
  2. django中使用原生SQL语句

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

sql

上一篇:如何在Linux中安装和使用bat命令

下一篇:springboot整合quartz定时任务框架的方法是什么

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》