mysql語句查 mysql中SQL語句查

2021-10-19 00:06:55 字數 575 閱讀 8544

show tables;檢視或顯示所有表名

show databases;檢視或顯示所有資料庫名

desc 表名;檢視表結構

select * form 表名;查詢表中所有欄位的值

select * from 表名 order by 指定欄位名 desc;按照指定字段降序查詢表中資料資訊

select * from 表名 order by 指定欄位名 asc;按照指定字段公升序查詢表中資料資訊

多表聯合查詢1

select * from goodstypeinformation gti,goodsinformation gi where gti.itemno=gi.itemno;

多表聯合查詢2

select gti.itemno,gti.goodstype,gi.itemseriestype,gi.goodsname from goodstypeinformation gti,goodsinformation gi where gti.itemno=gi.itemno or gti.itemno;

select 欄位1,欄位2,...  from 表名;查詢指定表中指定幾個欄位的值

Mysql增刪改查語句

增加 insert into 表名 欄位名1,欄位名2 value 字段值1,字段值2 例 insert into a id,name value 2,李四 刪除 delete from 表名 where 條件 例 delete from a where id 1 修改 update 表名 set ...

mysql語句阻塞 Mysql查詢阻塞的sql

select p2.host 被阻塞方host,p2.user 被阻塞方使用者,r.trx id 被阻塞方事務id,r.trx mysql thread id 被阻塞方執行緒號,timestampdiff second,r.trx wait started,current timestamp 等待時...

mysql優化的查詢語句 優化MySQL查詢語句

前言 查詢語句的優化是sql效率優化的乙個方式,可以通過優化sql語句來盡量使用已有的索引,避免全表掃瞄,從而提高查詢效率。最近在對專案中的一些sql進行優化,總結整理了一些方法。1 盡量避免在 where 子句中對字段進行 null 值判斷 應盡量避免在 where 子句中對字段進行 null 值...