一、查詢表數據
1、先進入表,使用命令:use 表名;。比如:use testdev;
2、再查看表里面的內容,使用命令:select *from 表名;。比如:select *from userInfo;
3、只查看某些特定的信息。
(1)、使用命令:select 字段名稱,字段名稱,.... from 表名;(大范圍的查找信息)。比如:select first_name,sex from userInfo;。
(2)、使用命令:select *from 表名 where 字段名稱="字段值"(數字不用加引號)(具體到某個字段的查看);
使用命令:select *from 表名 where 字段名稱!="字段值";。比如:select *from userInfo where sex!="boy";。
二、刪除表
使用命令:delete from 表名 where 字段名稱="字段值" and 字段名稱="字段值" and 字段名稱="字段值";。
比如:delete from userInfo where salary=2000 and id=1 and first_name="hi";。
三、修改表數據
使用命令:update 表名 set 字段名="字段值" where 字段名="字段值";。
從外部導入數據庫進入mysql
下載到C盤下(如果下載失敗就先下載到桌面再移到C盤下);
解壓后;
然后打開cmd,進入到C盤下的test_db-master里面;
導入employees數據庫;
mysql的基本查詢
1、全表查詢;
2、查詢部分字段;
3、條件過濾;
(1)、並且(and)
使用命令:select * from 表名 where 字段名='字段值' and 字段名='字段值";。
比如:select * from employees where first_name='Georgi' and last_name='Facello';。
(2)或者(or)
使用命令:select * from 表名 where 字段名='字段值' or 字段名='字段值";。
比如:select * from employees where first_name='Georgi' or last_name='Facello';。
下面其實還有很多數據,我沒有全部放出來,太多了。
(3)、包含(in)
使用命令:select * from 表名 where 字段名 in ("字段值","字段值") limit 數值;。
比如:select * from employees where last_name in ("charist", "Lamba") limit 6;。
(4)檢查范圍(between...and...)
使用命令:select * from 表名 where 字段名 between "字段值" and "字段值" limit 數值;。
比如:select * from employees where hire_date between "1986-12-01" and "1986-12-31" limit 9;
(5)、否定結果(not)
使用命令:select * from 表名 where 字段名 not between "字段值" and "字段值" limit 數值;。
比如:select * from employees where hire_date not between "1986-12-01" and "1986-12-31" limit 6;
(6)、匹配任意字符(%位置可任意放置)
使用命令:select * from 表名 where 字段名 like '不完整的關鍵字%' limit 5
比如:select * from employees where first_name like 'christ%' limit 5;
比如:select * from employees where first_name like '%ist%' limit 5;
比如:select * from employees where first_name like '%er' limit 5
(7)、ka前⾯任意兩個字符串,結尾為其他字符串的信息
(8)、以什么開頭(^)
(9)、以什么結束($)
(10)、使用重命名=別名(as)
(11)、對結果信息排序(降序由高到低)
對結果信息排序(升序由低到高)