查詢語句
select * from 表名; 查詢所有
select u_name,u_age from 表名; 查詢某幾條
查詢所有
條件 | 說明 |
--------------------- | -------------- |
> | 大於 |
>= | 大於等於 |
| < | 小於 |
| <= | 小於等於 |
| = | 等於 |
| != 或 <> | 不等於 |
| and | 並且 |
| or | 或者 |
| [not] between m and n | [不]在區間[m, n]區間 |
| [not] in () | [不]在指定集合中 |
| [not] like 條件 | 模糊匹配,%表示任意字符 |
舉個栗子:
select * from 表名 where age >= 20;
select * from 表名 where age <> 20;
select * from 表名 where age != 20 and age !=21;
select * from 表名 where name = 'dagou' or name = 'ergou';
select * from 表名 where age between 20 and 30;
select * from 表名 where age in (21,24,30);
select * from 表名 where name like "%gou%"; gou%:查詢開頭是gou,%gou%:查詢其中有gou的
插入語句
insert into 表名(id name, money, age, sex, province) values(3, '趙麗穎', 8000000, 31, 1, '河北');
注意:values後面對應的id值當id自增自減時可不寫
修改語句
update 表名 set age=31, money=10000000 where id=1;
解釋:找到age=31,money=10000000的對象,將其id設置爲1
刪除語句
delete from 表名 where id=2;
解釋:從指定的一個表中刪除id=2的一條數據