mysql 操作知識點

2021-08-10 23:57:36 字數 1521 閱讀 7787

update `tpshop_seller_goods` set `sall_numbe`=sall_numbe+1 where ( goods_id=162 )

返回值一直是0

原因是資料表中sall_numbe,沒有預設值0,新增第乙個資料時是空,空加1為空。

distinct

select

distinct(a.id), a.*,

b.type

from

table1 a

left join table2 b on a.sponsor_id = b.sponsor_id

where

b.type = 1

and a.sponsor_id = 10;

group by 

select 

a.*,

b.type

from

table1 a

left join ( select * from table2 group by sponsor_id ) as b on a.sponsor_id = b.sponsor_id

where

b.type = 1

and a.sponsor_id = 10;

max取唯一

select

a.*,

b.type

from

table1 a

left join ( select max( kid ), type, sponsor_id from table2 group by sponsor_id ) as b on a.sponsor_id = b.sponsor_id

where

b.type = 1

and a.sponsor_id = 10;

in

select

a.*

from

table1 a

where

a.sponsor_id in ( select sponsor_id from table2 where type = 1 and sponsor_id = 10 );

select

a.*,

1 from

table1 a

where

a.sponsor_id in ( select sponsor_id from table2 where type = 1 and sponsor_id = 10 );

解決辦法:

找到mysql的配置檔案

找到伺服器上面 /etc/my.cnf檔案,編輯

在檔案中加入一句:

sql_mode='strict_trans_tables,no_zero_in_date,no_zero_date,error_for_division_by_zero,no_auto_create_user,no_engine_substitution'

參考:

mysql常用知識點 mysql 常用知識點。

mysql u root p show databases show tables select from abc order by id limit 0,10 create database bbb exit mysqldump u root p game home backup.sql mysq...

二級mysql知識點 Mysql 知識點

1.死鎖回滾策略 死鎖發生時mysql會選擇行數少的事務進行回滾 2.鎖型別 共享鎖,排他鎖 行級鎖 innob record lock 鎖定單條記錄 gap lock 鎖定乙個範圍的記錄 但不包括記錄本身 next key lock 鎖定乙個範圍的記錄 並且包 含記錄本身 這是預設的鎖型別 更新操...

MySQL知識點2 表的操作

1.表的定義 表是乙個很重要的資料庫物件,包含資料庫中所有的資料,是組成資料庫的基本元素,由若干個字段組成。主要實現儲存資料記錄。表的操作包含建立表 檢視表 刪除和修改表。2.表的基本操作 建立表 create table table name 屬性名 資料型別,屬性名 資料型別 屬性名 資料型別 ...