This is the 12th day of my participation in Gwen Challenge

Author: Cola

Source: Coke’s path to data analysis

Please contact authorization for reprinting (wechat ID: data_COLA)

Query columns

In Excel, if you want to select only a few columns from a table, you just copy the column values and paste them into the new table.

1, Query a column

–select column name from table name; Select * from student where sname = sname

2, query multiple columns

Select * from sname, sage, sname, sage, sage, sage, sage, sage, sage, sage, sage, sage, sage, sage, sage, sage, sage, sage, sage, sage, sage, sage, sage, sage, sage

3, Query all columns

* –select * from table name; Query the values of all columns in the student1 table

Select * from table_name where table_name = 1;

Distinct –select Distinct column name from table name; [Bug Mc-10809] – De-weight sex column (meaningless)

Second, sort the value of the column

Filter and sort Excel ascending and descending order

1. Ascending order

Select * from table_name Order by; select * from table_name Order by; In ascending snum order

2. In descending order

Select * from table_name order by table_name DESC; Snum in descending order

3. Sort multiple columns

Select * from table_name order by table_name DESC, table_name ASC;

Three, the selection of lines

Excel in screening

1. Single condition screening

Select * from table_name where table_name = 1; Note:

  • Characters are quoted in single quotes
  • Order by is used after where

“=”

【 the 】

“>”

“< >”

[between]

2. Multi-condition screening

AND OR NOT AND: indicates that several conditions must be met at the same time. One of the several conditions can be met. No, NOT really

Select * from table where (select * from table where (select * from table where (select * from table where (select * from table where (select * from table where (select * from table where (select * from table where)))

Select * from sc where score > 60 and student id = 1

【 or 】

【and or at the same time 】

Note: AND and or can be used together. If no parentheses are added, the calculation of AND takes precedence

3、 IN

The function of IN is the same as that of OR

Select * from table_name where table_name = 1 and table_name = 2;

4, and the LIKE

The function of LIKE is similar to fuzzy lookup in Excel filter.

Select * from table where ‘like’;

The percent sign (%) represents any number of characters that you want to match.

Underscore (_) matches %, but only a single character.