当前位置:网站首页>Common database statements in unity

Common database statements in unity

2022-07-05 04:52:00 yaohuiyaoo

1. Create database
create database Database name ;
2. View all databases
show databases;
3. Use ( Get into ) database
use Database name ;
4. Delete database
drop database Database name ;
5. View all tables in the current database
show tables;
6. Delete a table
drop table Table name ;
7. Insert data into the table
insert into Table name ( Field )value( Corresponding type data );
8. Update data that meets the conditions
update Table name set Field name = data where Field = data
Be careful :where The latter is the condition , Satisfy where The following data can be modified to where The previous data
9. Delete data
delete from Table name where Field = data ;
10. Look up all the data in the table
select * from Table name
11. Query the data of some fields in the table
select Field 1, Field 2 from Table name ;
12. Query some fields in the table that meet the conditions
select Field 1, Field 2 from Table name where Field = data
13. Query a field that is not empty
select *from Table name where Field is null;
14. Several fields can be found and one field is not empty
select Field 1, Field 2 from Table name where Field is null;
15 Query the data starting with a word
select * from Table name where Field like ’ word %‘;
16. You can find out if you meet one condition
select * from Table name where Field = data or Field = data ;
17. Query data that meets multiple conditions at the same time
select *from Table name where Field = data and Field = data ;
18. Query data in a certain interval
select * from Table name where Field between data and data
19. Query to remove duplicate data
select distinct( Field ) from Table name where Field = data
20. In ascending order of a certain data
select * from Table name order by Field
21. Multi column sorting : When the first data is the same, sort according to the second requirement
select *from Table name order by Field desc , Field asc;
22. Limited number of queries
select * from Table name limit 0,3
23. Query data ( Internal connection )
select Field , Field from Table name inner join Table name on Primary key = Foreign keys ;
24 The cartesian product
select *from Table name , Table name where Primary key = Foreign keys ;
25. Left connection
select from Table name left join Table name on Primary key = Foreign keys ;
26 Query the average score of a certain item
select avg( Field ) from Table name ;
27. Query the highest score of an item
select max( Field ) from Table name ;
28. Query the lowest score of a certain item
select min( Field ) from Table name ;
29 Total number of query data
select count(
) from Table name ;
30 Total query score
select sum( Field ) from Table name ;
31. Group query
select * from Table name group by Field ;

原网站

版权声明
本文为[yaohuiyaoo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140626299108.html