You are here: Re: Please Help With Complex Update Statement Logic « MsSQL Server « IT news, forums, messages
Re: Please Help With Complex Update Statement Logic

Posted by pbd22 on 11/08/06 15:41

anybody else? this is driving me bonkers.

what i am trying to do is simply change a value of 0 to 1in
all rows where a given email address exists. i have to
use the select in the where clause because i need to join
2 tables (where e.public_name = 'professor').

if you dont have an idea how to acheive this given the code i
have posted, maybe you could do this on your own DB and
show me the code?

any leads much appreciated.

thanks.

pbd22 wrote:
> yes, thank you.
> i have done that and the results are as expected.
> the left-hand side of the OR condition evaluates,
> so, all values that are 0 and have the mag... email
> address are returned. the right-hand side does
> not evaluate. if i run the statement with the AND
> condition, i get nothing back.
>
> Alex Kuznetsov wrote:
> > pbd22 wrote:
> > > thanks for the suggestion,
> > > but the results are still the same - all the rows update
> > > to the new value, not just the single, intended row.
> > >
> > > other thoughts?
> >
> > Test your WHERE clause as follows:
> >
> > SELECT * FROM add
> > WHERE (add.add_status = 0 and add.add_email = 'mag...@rice.edu' )
> > or add_s in
> > (
> > SELECT a.add_s
> > FROM add a, edit e
> > WHERE a.email_address = e.email_address
> > and e.public_name = 'professor'
> > )
> >
> >
> >
> >
> > -----------------------
> > Alex Kuznetsov
> > http://sqlserver-tips.blogspot.com/
> > http://sqlserver-puzzles.blogspot.com/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация