MySQL控制台实现模糊查询及去重查询

1.

去重复数据,字段前加distinct

select distinct first_name from actor order by actor_id desc;

查询actor_id不等于1的数据

select * from actor  where actor_id <> 1;

多条件查询 and,  or , not , in,not in,between and

select * from actor  where actor_id <> 1 and first_name='ED';

select * from actor  where not  first_name='ED';

select * from actor  where actor_id <> 1 or first_name='ED';

select * from actor  where actor_id in ( 1,2,3);

select * from actor  where actor_id not in ( 1,2,3);

select * from actor  where actor_id between 1 and 9;
模糊查询like,not like(%代表0-n个字符,_代表一个字符)

select * from actor where first_name  like 'P%';

select * from actor where first_name  like 'P_____';



你可能感兴趣的:(MySql)