Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
gwunta
Starting Member
2 Posts |
Posted - 2011-03-09 : 10:57:57
|
| Hi guys, Ive had very little experience with SQL and am trying to work out how to copy the contents of a field matching a certain criteria into another table AND adding a literal value for each row in the destination table.IETABLE_DESTPRODUCTID, PRODUCT_TYPE_IDWhere each value in the PRODUCTID field would be copied from TABLE_SRC based on some criteria and then the value 9 lets say, be entered into the PRODUCT_TYPE_ID field.This is what I have at the momentINSERT INTO jos_vm_product_product_type_xref (product_id,product_type_id) SELECT product_id FROM jos_vm_product WHERE attribute like 'Size,One%','9'Any help would be very much appreciatedThank you in advance |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-03-09 : 11:01:36
|
| [code]INSERT INTO jos_vm_product_product_type_xref (product_id,product_type_id)SELECT product_id,'9'FROM jos_vm_productWHERE attribute like 'Size,One%'[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
gwunta
Starting Member
2 Posts |
Posted - 2011-03-09 : 11:09:43
|
| Thankyou so so much, I wasnt far off the mark after all. VERY much appreciated. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-03-09 : 11:18:40
|
| wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|