(五 2)Mysql的基本查詢語句

2021-10-01 03:28:56 字數 1336 閱讀 1258

一、查詢select

語法:select 列名稱 from 表名稱     (其中  * 代表選擇顯示全部的列)
1、無條件查詢

select * from zhprny   即:查詢zhprny這個表中的所有列
2、帶條件查詢

語法 :  select 列名稱 from 表名稱 where 列 運算子 值

(運算子有=、<=、!=、>=、<、>、<>、like、between)

常用例項:

等號的使用

select employeeid,lastname,firstname

from employees

where employeeid=1 /*查詢employeeid等於1的資料

select * from zhprny where name='張三'    

/*查詢zhprny這個表中name='張三'的所有列,張三是字串要用單引號,要英文的單引號。

like的使用

select employeeid,lastname,firstname /*查詢lastname首字母為f的資料*/

from employees

where lastname like 'f%'

between的使用

select employeeid,lastname,firstname /*查詢employeeid 在1到9之間的資料(包含1和9)*/

from employees

where employeeid between 1 and 9

and(前後兩個條件需要全部成立)

select employeeid,lastname,firstname /*查詢titleofcourtesy='mr.' 並且 lastname='buchanan'*/

from employees

where titleofcourtesy='mr.' and lastname='buchanan'

or(前後任意乙個條件成立即可)

select employeeid,lastname,firstname /*查詢titleofcourtesy='mr.' 或者 lastname='buchanan'*/

from employees

where titleofcourtesy='mr.' or lastname='buchanan'

不斷更新……

2 MySQL 運算元據庫的語句

2 資料庫的列型別 3 資料字段屬性 4 建立資料庫表 5 修改資料庫 6 刪除資料表 運算元據庫 運算元據庫中的表 運算元據庫中表的資料 mysql關鍵字不區分大小寫 creat database if not exists 資料庫名 drop database if exists 資料庫名 ta...

2 MySQL基礎 基礎查詢介紹

基礎查詢 語法 select 查詢列表 from 表名 1 查詢列表可以是 表中的字段 常量值 表示式 函式 2 查詢的結果是乙個虛擬的 查詢單個字段 select error code from error log 查詢多個字段 select error name thread id from e...

mysql基本查詢語句

資料庫操作的sql語句 show database create database 資料庫名 charset utf8 use 資料庫名 select database drop database 資料庫名 表結構操作的sql語句 show tables create table students ...