T-SQL資料庫中兩個表之間的操作,t-sql資料庫操作

來源:互聯網
上載者:User

T-SQL資料庫中兩個表之間的操作,t-sql資料庫操作

--根據另一張表修改表中的資料
update Admin_FCOutDt set oLastId=T.contractID from (select crm_contract.contractTopic,crm_contract.contractID from Admin_FCOutDtleft join crm_contract on Admin_FCOutDt.ContractName=crm_contract.contractTopic)Twhere Admin_FCOutDt.ContractName=T.contractTopic--把查詢另一張表insert into Admin_FCOutDt(protype,number)select '測試',num from crm_contract --根據另一張表刪除表中的資料delete from Admin_FCOutDt where LastId in (select id from Admin_FCOut where prod like '%EF%')--兩表合并查詢(兩個表之間的查詢只列出這一個。會有單獨的章節介紹)select fnumber ,fname from Admin_FCOutDt where state=1union allselect nub as fnumber,fname  from crm_comtract 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.