Database knowledge point accumulation day01

column deduplication

1. Use the DISTINCT keyword to deduplicate

SELECT DISTINCT(university)

FROM user_profile
2. Use GROUP BY to group, group back to create a temporary table

SELECT university
FROM user_profile
GROUP BY university

Query results limit the number of rows returned

select device_id from user_profile limit 2;
select device_id from user_profile limit 0,2;
select device_id from user_profile where id <=2;

limit 0, 2 means starting from the first piece of data (0 means the first piece), only 2 pieces of data are displayed per page
The first number indicates the starting address, and the second indicates the offset

Find user information other than Fudan University

select  device_id, gender,age,university from user_profile where university!="复旦大学"

Use where to filter empty values ​​exercise

select device_id,gender,age,university from user_profile where age is not null


select device_id,gender,age,university
from user_profile
where age !='

Where in 和Not in

select device_id ,gender,age,university,gpa from user_profile where university in('北京大学','复旦大学','山东大学')

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324146798&siteId=291194637