October 30, 2008 at 1:20 am
Hi,
i want update 'disabled' column in tasks table based on projectid.
projectid in milestones table
milestoneid in milestones and tasks tables
this is my query
update tasks as t set t.disabled=1, milestones as m
where t.milestoneid=m.milestoneid and m.projectid=15
but i got an error like
Incorrect syntax near the keyword 'as'.
how can i do this?
Regards
Eswar
October 30, 2008 at 1:27 am
Did u try removing the 'as' ?
October 30, 2008 at 1:34 am
i have gave a alias name of table
how can i merge the two table in update query?
October 30, 2008 at 2:06 am
Eswar, you code is close:
UPDATE t SET disabled = 1
FROM tasks AS t, milestones AS m
WHERE t.milestoneid = m.milestoneid
AND m.projectid=15
Using proper join syntax this is
UPDATE t SET disabled = 1
FROM tasks AS t
INNER JOIN milestones AS m
ON t.milestoneid = m.milestoneid AND m.projectid=15
Cheers
ChrisM
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply