all groups > sql server new users > march 2006 >
You're in the

sql server new users

group:

Help with query


Re: Help with query Tom Moreau
3/22/2006 12:00:00 AM
sql server new users: Please post your DDL. It's not clear to which table object_type belongs.

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
..
[quoted text, click to view]
This is my select statement

SELECT *
FROM Attachments
inner join attachmentlinks on Attachments.attachment_Id =
Attachmentlinks.attachment_id
WHERE object_type = 'emp'


I need to update attachments table and set visibleindividual = 0
where object_type = 'emp'

Problem is that object_type is in the attachmentlinks table, we can join
them but I don't know how to construct the update statement with this
clause, any help is greately appreciated

Aleks

Help with query Alejandro
3/22/2006 1:37:05 AM
This is my select statement

SELECT *
FROM Attachments
inner join attachmentlinks on Attachments.attachment_Id =
Attachmentlinks.attachment_id
WHERE object_type = 'emp'


I need to update attachments table and set visibleindividual = 0
where object_type = 'emp'

Problem is that object_type is in the attachmentlinks table, we can join
them but I don't know how to construct the update statement with this
clause, any help is greately appreciated

Aleks

Re: Help with query Hugo Kornelis
3/23/2006 12:18:46 AM
[quoted text, click to view]

Hi Aleks,

UPDATE Attachments
SET visibleindividual = 0
WHERE EXISTS
(SELECT *
FROM attachmentlinks
WHERE Attachments.attachment_Id = attachmentlinks.attachment_id
AND attachmentlinks.object_type = 'emp')

(untested - see www.aspfaq.com/5006 if you prefer a tested reply)

--
AddThis Social Bookmark Button