Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 25, 2012 10:12 AM by siddharth_kcr
Member
26 Points
30 Posts
Feb 24, 2012 10:54 AM|LINK
Hi
Sql1 = "select uid,fnm,lnm,role from members where uid=@uid and pwd=@pwd"
Sql2 = "update members set online=true where uid=@uid"
Can I combine both quries into one?
Participant
986 Points
247 Posts
Feb 24, 2012 11:03 AM|LINK
If the select query returns only one value then you can write it like update XXXX where uid=(select first XXX)
All-Star
18926 Points
3662 Posts
Feb 24, 2012 11:09 AM|LINK
not sure but try something like this
UPDATE members set online = case when mem.exist =1 then 1 else 0 from ( select uid,fnm,lnm,role case uid when null then 0 else 1 end as exist from members where uid=@uid and pwd=@pwd ) mem
117320 Points
8000 Posts
Moderator
MVP
Feb 24, 2012 04:30 PM|LINK
Sql1="select uid,fnm,lnm,role from members where uid=@uid and pwd=@pwd;update members set online=true where uid=@uid"
Feb 25, 2012 10:12 AM|LINK
Thanks it worked..
siddharth_kc...
Member
26 Points
30 Posts
Combine update and select queries
Feb 24, 2012 10:54 AM|LINK
Hi
Sql1 = "select uid,fnm,lnm,role from members where uid=@uid and pwd=@pwd"
Sql2 = "update members set online=true where uid=@uid"
Can I combine both quries into one?
dinesh kumar...
Participant
986 Points
247 Posts
Re: Combine update and select queries
Feb 24, 2012 11:03 AM|LINK
If the select query returns only one value then you can write it like update XXXX where uid=(select first XXX)
Jai Jagannath
shashankgwl
All-Star
18926 Points
3662 Posts
Re: Combine update and select queries
Feb 24, 2012 11:09 AM|LINK
not sure but try something like this
All is well if it runs well.
blog
limno
All-Star
117320 Points
8000 Posts
Moderator
MVP
Re: Combine update and select queries
Feb 24, 2012 04:30 PM|LINK
Format your SQL query with instant sql formatter:
http://www.dpriver.com/pp/sqlformat.htm
siddharth_kc...
Member
26 Points
30 Posts
Re: Combine update and select queries
Feb 25, 2012 10:12 AM|LINK
Thanks it worked..