Solved

Update Query

Posted on 2004-09-16
1
141 Views
Last Modified: 2010-04-05
Can anyone tell me why my update query does not work.  I get the error.

Server: Msg 116, Level 16, State 1, Line 17
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.


UPDATE up
SET up.ref = up.ref,
    up.pdate = up.pdate,
    up.problem = up.Problem,  
    up.Branch    = up.Branch ,
  up.Val =  v.val,
    up.moddate =  v.modified ,  
   up.type  = t.name
from  docsdb.dbo.vtab0010 v,  docsdb.dbo.temp  te,  docsdb.dbo.updated up,  docsdb.dbo.types t
where v.val in
(select  distinct te.ref,
                 te.pdate,
                 v.val,
                 te.problem,
                 te.branch,
               v.modified,
               t.name
           from   docsdb.dbo.vtab0010 v      
           join   docsdb.dbo.docs d on v.docid = d.docid
           join   docsdb.dbo.types    t on d.typid = t.typid
           join   docsdb.dbo.temp     te on v.val = te.val
           inner join (select v.val, max(v.modified) as modified from docsdb.dbo.vtab0010  v group by v.val)
           x on v.val = x.val and v.modified = x.modified
           where  (v.val = te.val and te.problem = 'No Card'))
0
Comment
Question by:running32
1 Comment
 
LVL 13

Accepted Solution

by:
BlackTigerX earned 500 total points
ID: 12079886
your problem is here:

where v.val in
(select  distinct te.ref,
                 te.pdate,
                 v.val,
                 te.problem,
                 te.branch,
              v.modified,
              t.name

v.val IN ALL THOSE values, you can only have ONE value in your select statement, so it needs to be something like:

where v.val in
(select  v.val,
            ...etc...
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question