Solved

Update Query

Posted on 2004-09-16
1
137 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now