SQL Recipes
A FREE cookbook for SQL queries and examples
Register FAQ Search Today's Posts Mark Forums Read

SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it.

Go Back   SQL Recipes a FREE cookbook of SQL queries and examples > SQL queries and examples > SQL - Questions and Answers

Reply
 
LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 05-04-2007, 04:27 PM
Unregistered
 
Posts: n/a
Default ANY dialect question:

update table


i need to update 4 columns of a table..
out of dat 3 columns need to updated without any conditions and the 4th one need to updated with a certain condition..
so is there any way to do this in a single query?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

ANSWER(S):

  #2 (permalink)  
Old 05-07-2007, 08:10 AM
Dimitar
 
Posts: n/a
Default ANY answer. Re: update table

Quote:
Originally Posted by Unregistered View Post
i need to update 4 columns of a table..
out of dat 3 columns need to updated without any conditions and the 4th one need to updated with a certain condition..
so is there any way to do this in a single query?
What is the 4th column condition?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-07-2007, 08:13 AM
ankur.bhargava
 
Posts: n/a
Post ANY answer. Re: update table

placing the column in a case block will work for you

Update table1
set column1=@value,
column2=@value,
column3=@value,
column4=case (condition) @value Else,column4 End case
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-07-2007, 08:26 AM
Unregistered
 
Posts: n/a
Default ANY answer. Re: update table

Quote:
Originally Posted by ankur.bhargava View Post
placing the column in a case block will work for you

Update table1
set column1=@value,
column2=@value,
column3=@value,
column4=case (condition) @value Else,column4 End case
yes!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:55 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Copyright (c) 2006-2008 SQL Recipes

1 2 3 4 5 6 7 8