Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use SQL statements

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how to use sql statements. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Update

1. Set A field sets the password of the second record (bs is 2) to'* *'in the table t_test. 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) |

% means that any host can connect

Android Sqlite

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

-- select * from message where readstatus 0ram data whose readstatus is not equal to 0

-- select * from message where sender='13455556661' and receiver='13455556663' and process=103 order by _ id desc

-- select * from message limit 3-query only the first three pieces of data

-- select * from message limit 2 match 1 match-specify the offset and the number of query data items

Select count (1) from message;-- query the number of items in the message table

two。 Database query statement

Select * from message order by _ id asc; in ascending order of _ id

Select * from message order by _ id desc; in descending order of _ id

2.1

Select sender,receiver,content from message group by sender order by _ id desc

When order by and group by are used together, use group by first, then order by

4. About deletin

Delete the SQL statement for a record of _ id=2 from the message table:

Delete from message where _ id ='2'

Reference: 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 = 1314 iconocracies, 13 legends, 13 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'; floor

Thank you for reading! This is the end of the article on "how to use SQL sentences". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report