1. 程式人生 > >5、mysql資料內容操作(查詢、插入、修改、刪除)

5、mysql資料內容操作(查詢、插入、修改、刪除)

操作環境:cmd命令視窗

1、插入資料

插入多項:insert into 表名(欄位1,欄位2) values(值1,值2);

注意:插入字元需要用雙引號擴住“”

insert into table_name(field1,field2....fieldN)VALUES (value1,value2,...valueN);

2、修改資料

UPDATE table_name SET field1=new-value1,field2=new-values where ...

3、查詢資料

select 列名1,列名2......from 表名 【where】

4、過濾重複值

select distinct 列名1 from 表

5、合併兩列

select  tcontect  (列名1,列名2)from 表名   

6、修改列名

select 列名1 as 別名,列名2 as 別名  from表名

7、模糊查詢

select 列名...from 表名 where 列名 like ‘%字元竄%’

8、刪除資料

delete from 表名

truncate table 表名