mysql關聯表更改表多個字段值

2022-07-26 21:18:17 字數 1014 閱讀 7371

關聯表更改某乙個字段值:更改部分資料,外層where條件控制更改記錄的數量
begin

;update sturgeon_summary s set s.set_date = (select set_date from sturgeon_set_pay p where s.set_no = p.set_no ) where s.merchant_no ="300900100390

" ;select

*from sturgeon_summary where merchant_no ="300900100390

";rollback;--

commit;

關聯表更改某乙個字段值:更改全部記錄
begin

;update sturgeon_summary s set s.merchant_no = (select merchant_no from sturgeon_set_pay p where s.set_no = p.set_no );

select

*from

sturgeon_summary;

rollback;--

commit;

關聯表更改多個字段值:

begin

;update sturgeon_summary s set s.set_date = (select set_date from sturgeon_set_pay p where s.set_no = p.set_no ),s.merchant_no = (select merchant_no from sturgeon_set_pay p where s.set_no = p.set_no ) where s.set_no =

"m2201904290100100010039093733702";

select

*from

sturgeon_summary;

rollback;--

commit;

mysql 連表分組 多個欄位用逗號隔開

select group concat plate tag.plate id from tag left join plate tag on plate tag.tag id tag.id where tag deleted at is null and plate tag deleted at i...

mysql 函式多個連線 mysql 多個字段拼接

mysql的查詢結果行欄位拼接,可以用下面兩個函式實現 1.concat函式 mysql select concat 1 2 3 from test concat 1 2 3 123 如果連線串中存在null,則返回結果為null mysql select concat 1 2 null,3 fro...

mysql建立表多個欄位的唯一約束

mysql中有些表有時需要做一些欄位的唯一約束,當然你也可以在insert前判斷有無的方式來防止重複,如果不想額外增加 來更靈活的實現一些欄位的唯一約束,mysql提供了兩種方式 1.unique key alter table xx add unique key no account no,col...