The SELECT statement is used to query data from a table.
The results are stored in a results table.
Writing:
select *(this is the field to look for) from (write table name here);
Example: (There are sno, sname, ssex, class and other fields in the xuesheng table)
If you want to query the two fields of sno and ssex, they are written as follows:
select sno,ssex from xuesheng;
If you want to query all data in a table, replace all fields with *, and write as follows:
select * from xuesheng;
Cancel duplicate distinct usage:
select distinct (field name) from (table name);
example:
select distinct sno from xuesheng;
Conditional query where:
select * from (table name) where (field name)=(condition);
example:
select * from xuesheng where class='95033';
and (and), or (or):
The AND operator displays a record if both the first and second conditions are true.
The OR operator displays a record if only one of the first and second conditions is true.
Conditional queries The between:BETWEEN operator selects values in the data range between two values. These values can be numbers, text, or dates.
selecr * from (table name) where (field name) between (condition 1) and (condition 2);
example:
select * from xuesheng where sno between 101 and 105;
fuzzy query like;
select * from (table name) where (field name) like '(condition)';
example:
select * from xuesheng where sname like '%王%';
Among the characters to be searched, there are 2 characters with special meanings:
1: % means: any character representing any number
2: _ means: any character representing 1
3: The characters here refer to a "symbol" visible in reality, not a byte.