SQL Update based on and Select Result From Same Table -


I clearly describe what I am trying to do.

I am using DBISAM SQL Database.

We sell T-shirts, and various types of different types I am trying to update our product database with the values ​​of other products in the database. Here is a sample:

Product Table

  SKU Product LongDesk 01-S 01 Great looking T-shirt 01-M 01 01-L 01 02-S01 02- M 01 Amazing Ladies T 02-L 01 03-32 03 Long T 03-34 03 03-36 03 I would like to write an updated script which will be  LongDesc  SKU  is not  long disk  in the  field, but I like that < LongDesc  other < product       SKU Product Longsec 01-S01 c Writing Looking T-Shirt 01-M 01 Great Looking T-Shirt 01-L 01 Great Looking T-Shirt 02-S 01 Amazing Ladies T 02-M 01 Amazing Ladies T 02-L01 Amazing Devices T 03-32 03 Long Tea 03-34 03 Long T 03-36 03 Length T   

Thank you in advance for your help!

Try this:

  UPDATE p SET p.longdesc = pp .longdesc FROM PRODUCTS P INNER (select a.sku, MAX (a.longdesc) as longdesc FROM (SELECT LEFT (SKU FOR (POS ('-', SKU-1)) SUU, from long DCC products A group by S. Sku) left on PP (P. SKU for (POS ('-', P.Sc.U.U.) - 1)) = PP.Scu   < / Div> 

Comments