---
title: "Uppdatera kolumn där jag hittar flera id'n..."
type: "forum-thread"
url: "https://www.webforum.nu/amne/databaser-sql/175204-uppdatera-kolumn-där-jag-hittar-flera-id-n"
topic: "Databaser & SQL"
topic_url: "https://www.webforum.nu/amne/databaser-sql"
author: "CatZ"
published: "2008-11-06T14:52:33.000Z"
updated: "2008-11-06T17:23:35.000Z"
replies: 1
views: 362
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/databaser-sql/175204-uppdatera-kolumn-där-jag-hittar-flera-id-n"
---

# Uppdatera kolumn där jag hittar flera id'n...

## #1 — CatZ, 2008-11-06T14:52Z

```
update ent_subscription
set ent_subscription  = convert(char(20),dateadd(yy,datediff(yy, ent_subscription, '2008-10-01 00:00:00.000'),ent_subscription),112 )
where ent_subscriptionid in 
	(
		select expdate.ent_subscriptionid
		from subscription s
			inner join ent_subscription cty on s.subscriptionid=cty.f_subscription
				and cty.f_type_ent_subscription=15

			inner join ent_subscription expdate on s.subscriptionid=expdate.f_subscription
				and expdate.f_type_ent_subscription=30

		where  cty.ent_subscription = '47' 
			and datediff(mm, expdate.ent_subscription, '2008-10-01') > 0
	)
```

Alltihop fungerar jättebra utom just att uppdatera. Hur kan jag uppdatera where id = något av id'na i min select statement? Om jag specificerar ett av id'na med 

```
where ent_subscriptionid = 123123
```

så går det jättebra! \*trött\*

Permalänk: https://www.webforum.nu/p/175204

## #2 — Peter S, 2008-11-06T17:23Z

Vänta här nu... Om inte uppdateringen fungerar, vad är det då som går bra :p

```
update
    ent_subscription
set
    ent_subscription = convert(char(20),dateadd(yy,datediff(yy, expdate.ent_subscription, '2008-10-01 00:00:00.000'),expdate.ent_subscription),112 )
from
    subscription s inner join ent_subscription cty
    on
    s.subscriptionid = cty.f_subscription and
    cty.f_type_ent_subscription = 15
        inner join ent_subscription expdate 
        on 
        s.subscriptionid = expdate.f_subscription and 
        expdate.f_type_ent_subscription = 30
where
    cty.ent_subscription = '47' and 
    datediff(mm, expdate.ent_subscription, '2008-10-01') > 0
```

Permalänk: https://www.webforum.nu/p/2152499

---

Tråden på webben: https://www.webforum.nu/amne/databaser-sql/175204-uppdatera-kolumn-där-jag-hittar-flera-id-n
