Get the App
SLTechnology News&Howtos  ›  Database  › 

Commonly used SQL statements (1)

Shulou Source: shulou.com Published: 2022-06-01 08:43:37 10月02日 Update

Createtable#tmp (uuidint,cNamenvarchar (50)) insertinto#tmpvalues (1gime 'apple') insertinto#tmpvalues (2je 'grape') insertinto#tmpvalues (1meme 'apple 111') insertinto#tmpvalues (2meme' grape 111') insertinto#tmpvalues (1meme 'apple 222') insertinto#tmpvalues (third' orange')-query Select*from#tmp-- to put the results together Selectx.uuid,left (cName,len (cName)-1) ascNamefrom (Selectuuid, (SelectcName+') 'from#tmpwhereuuid=t1.uuidforxmlpath (') ascNamefrom#tmpast1groupbyuuid) xps: this function can only be achieved with forxml in SQL SERVER.

-- add a record insertinto [dbo]. [T _ BU_STOCK] ([STORAGE_YEAR], [STORAGE_MONTH], [STORAGE_DAY], [STORAGE_DATE], [VEHICLE_BELONG], [CAR_SERIES_CODE]) Values ('2015, July 22, 2015, July 22, 2015, July 22, 2015)

-- add records insertinto#T_BU_STOCK ([STORAGE_YEAR], [STORAGE_MONTH], [STORAGE_DAY], [STORAGE_DATE], [VEHICLE_BELONG], [CAR_SERIES_CODE]) Select 2015Ji 22, 2015-07-22.

The results of the query table insertinto#T_BU_STOCK ([STORAGE_YEAR], [STORAGE_MONTH], [STORAGE_DAY], [STORAGE_DATE], [VEHICLE_BELONG], [CAR_SERIES_CODE]) Select 2015Ji 22, Jul 22, 2015, July 22, 2015 (July 22, 2015)

-- execute the stored procedure (the value returned by the stored procedure must be consistent with the column value of the added table) insertinto#T_BU_STOCKEXECPdd_Stock

-- backup table Select*intoT_BU_DLR_2015_08_20fromT_BU_DLR-- to create temporary table Select*into#T_BU_DLR_2015_08_20fromT_BU_DLR

Tags: Result Apple Grape procedure Storage query consistency Writing function only backup method query Table Orange Common statement Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Huawei Xiaomi Redmi Docker