Results 1 to 3 of 3

Thread: help!

  1. #1
    Join Date
    Apr 2004
    Posts
    16

    Unanswered: help!

    i have got a sql language ,but i cant understand what is the meaning of "select 1 ......" the following

    update tempconsumerec1 set flag='4' where flag='1' and offlineno=(select offlineno from dup_cardmaxoffline where cardno = tempconsumerec1.cardno) or offlineno<(select offlineno from dup_cardmaxoffline where cardno= tempconsumerec1.cardno) and (not exists(SELECT 1 FROM dup_cardmaxoffline where cardno = tempconsumerec1.cardno))

    I need you help !

  2. #2
    Join Date
    Jun 2003
    Posts
    140

    Smile

    Hi,

    The update statement includes subquery and in subquery a single row
    should be returned as a result so following condition simply checks that
    if any cardno matches with tempconsumerec1's cardno and even if there are more then single cardnos are matching it will return 1 (i.e. single row) as a result

    (not exists(SELECT 1 FROM dup_cardmaxoffline where cardno = tempconsumerec1.cardno))

    hope this helps

  3. #3
    Join Date
    Mar 2001
    Location
    Lexington, KY
    Posts
    606
    liutao9:

    It is the same reason as this thread:
    http://www.dbforums.com/t996966.html

    Someone thought it was an optimzation to write SELECT 1 instead of SELECT * -- but it's not; they are the same.
    Thanks,

    Matt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •