mysql之select 查詢表資料(一)

2021-07-24 22:07:56 字數 1086 閱讀 4178

1,select * 用於選擇表中的所有列

2,單獨查詢某些列,用逗號隔開即可

-----and,or ,>,< >=,<= ,=,<>不等於,in,not in,between and,not匹配相反,not null非空

----like 搭配萬用字元_:乙個字元,%:乙個或多個字元

----example:

select * from students where gender = '女'

and name = '小梅';

select * from students where birthday > '1993-04-05';

select * from students where id in (1,3);

select * from students where id = 1

or name = '小紅';

select * from students where name like

'小%';

select * from students where id <> 2;

select * from students where name like

'_東%';

4,在表dual 可用於計算

----加(+)、減(-)、乘(*)、除(/)、求于(也叫模運算%)等等

注:如果插入資料有單引號,必須用單引號』或反斜槓\轉義

mysql之select語法常用查詢舉例

1.去重查詢 select distinct id,age from table name 2.指定列查詢 select id,name from table name 3.語句運算 select id,name,english math chinese from table name 4.起別名 ...

mysql查詢關係表 MySQL查詢之關係查詢

連線查詢 select table b.type,table b.title,table b.content,table b.author from table a left join table b on table a.type table b.type where table a.id 1 子...

Mysql之SQL語句 select聯表查詢

1.連表查詢 現有表1 student 列1 d 列2 name 和 表2 score 列1 id 列2 fraction select student.name,score.fraction from student,score where student.id 1 and score.id 1 ...