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 |
|
derekg
Starting Member
1 Post |
Posted - 2005-11-23 : 06:51:33
|
| Hi allI am trying to do the following and just cant work it out!1) Get all rows meeting my where criteria (using a subquery)2) Update all those rows with their original value and a string appended (the string is '474,')Here is my code so far:UPDATE content_attributeSET cat_value = '474,' + (SELECT DISTINCT CAST(cat_value AS varchar) FROM dbo.content_attribute CA WHERE CA.cat_civ_cit_id IN ( SELECT DISTINCT cit_parent_cit_id FROM contentItem CI WHERE cit_id IN ( SELECT DISTINCT cat_civ_cit_id FROM content_attribute WHERE cat_value LIKE '%102%' AND cat_ade_id = 379 ) AND CI.cit_parent_cit_id IS NOT NULL AND CI.cit_parent_cit_id < 5000 ) AND CA.cat_ade_id = 373 AND CA.cat_civ_version = (SELECT MAX(cat_civ_version)AS civMax FROM dbo.content_attribute CAMax WHERE cat_civ_cit_id = CA.cat_civ_cit_id AND cat_ade_id = 373) )WHERE cat_ade_id = 373AND cat_civ_cit_id = CA.cat_civ_cit_id --where it breaksAND cat_value NOT LIKE '%474%'ThanksDerek |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-11-23 : 07:35:56
|
| Are u getting any errors .. ???and i guess you should do somthing like this .. UPDATE content_attributeSET cat_value = '474,' + CAST(CA.cat_value AS varchar) FROM dbo.content_attribute CAWHERECA.cat_civ_cit_id IN(SELECT DISTINCT cit_parent_cit_idFROM contentItem CIWHEREcit_id IN(SELECTDISTINCT cat_civ_cit_idFROM content_attributeWHERE cat_value LIKE '%102%'ANDcat_ade_id = 379)ANDCI.cit_parent_cit_id IS NOT NULL ANDCI.cit_parent_cit_id < 5000)ANDCA.cat_ade_id = 373AND CA.cat_civ_version = (SELECT MAX(cat_civ_version)AS civMax FROM dbo.content_attribute CAMax WHERE cat_civ_cit_id = CA.cat_civ_cit_id AND cat_ade_id = 373))WHERE cat_ade_id = 373AND cat_civ_cit_id = CA.cat_civ_cit_id --where it breaksAND cat_value NOT LIKE '%474%'Sucess Comes to those who Believe in Beauty of their Dream.. |
 |
|
|
|
|
|