mysql常用語句

1、用戶A表的某一列更新B表的某一列
eg:用t2表的c_account_id替換t1表的c_counter_part_id字段

update t_invest_account_cashflow t1 set
 t1.c_counter_part_id=(select t2.c_account_id from
 t_invest_account t2 where
 t1.c_invest_account_id=t2.c_invest_account_id )

2、產生自增編號
rowNum將從1開始自增

set @row=0;
select c_account_cashflow_id ,@row:=@row+1 rowNum 
 from t_account_cashflow where
 c_account_cashflow_id ;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章