Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa SQL using case in update statement
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


rudranarayana samal
using case in update statement
2 Answer(s)      3 years and 11 months ago
Posted in : SQL


i want to use case in update clause. i have used case in select stmt referring answer in this site. but the same syntax is not working for update stmt.my problem is update emp set case deptno when 10 then 20 when 20 then 30 when 30 then 40 when 40 then 10 else 0 end where deptno in(10,20,30,40); But it is not working. slightly change in the syntax working but for first condition only update emp set deptno=(case when 10 then 20 when 20 then 30 when 30 then 40 when 40 then 10 else 0)end;


Advertisement
View Answers

November 13, 2010 at 3:57 PM


Hello Friend,

Try this:

update emp set deptno= case
   when deptno= 10
     then deptno* 20
when deptno= 20
     then deptno* 30
when deptno= 30
     then deptno* 40
when deptno= 40
     then deptno* 10
else deptno* 0
end

Thanks



November 16, 2010 at 4:28 PM


thanks friend i got the query for case in update right.

with regards



Related Tutorials/Questions & Answers:
using case in update statement
using case in update statement  i want to use case in update clause... syntax is not working for update stmt.my problem is update emp set case deptno... working but for first condition only update emp set deptno=(case when 10 then 20
Find Capital using Switch-Case statement
Find Capital using Switch-Case statement In this Java Tutorial section, we are going to find the capital of our states using Switch-Case statement. For this, we have created two arrays i.e. array of states and array of capitals. Then we
Advertisements
CASE IN UPDATE IN MYSQL
CASE IN UPDATE IN MYSQL  I WANT THE SYNTAX FOR USING CASE IN UPDATE STMT IN MYSQL.ANY ONE PLEASE HELP.   Hi Friend, Visit here Thanks
Update statement
Update statement  I create a access database my program When I click add button bata are adds to the my data base but when i click update button my database is not update I write this program using 3 differfnt notepad pages MY
Update Record using Prepared Statement
JDBC: Update Record using Prepared Statement In this section, you will learn how to update row using Prepared Statements. Update Record  ... statement. Update record is most important operation of database. You can update one
update statement in mysql
update statement in mysql  i am looking for mysql update statement example. Thanks
The Update Statement in SQL.
The Update Statement in SQL.  The Update Statement in SQL.   Hi, here is the answer, The update statement in the sql is written as follows- UPDATE table_name SET column_name = new_value WHERE column_name = some_value
JDBC Update Statement Example
.style1 { text-align: center; } JDBC Update Statement Example JDBC update statement is used to update the records of a table using java application program. The Statement object returns an int value that indicates how many
update statement in mysql
update statement in mysql  Update statement to update the existing... and use the update query to update the record. To update record, we write query ?UPDATE student SET fieldName=??? WHERE fieldName=?? . You can SET value
The UPDATE Statement
The UPDATE Statement       The UPDATE statement is used to modify the data in the database table through a specified criteria. In the given syntax of update statement the keyword SET
callable statement,stored procedure for insert data and also for update data into oracle database using jsp
callable statement,stored procedure for insert data and also for update data into oracle database using jsp  iam a fresher newbie to softparsing i have one task to do soft parsing tl asked to do callable statement,stored
Update Records using Prepared Statement
Update Records using Prepared Statement   ... the process of updating the records by using the PreparedStatement.  Here arise a question, what is updating the records. In the case of relational database
The UPDATE Statement, SQL Tutorial
The UPDATE Statement       The UPDATE statement is used to modify the data in the database table through a specified criteria. In the given syntax of update statement the keyword SET
JDBC Prepared Statement Update
Statement Update is used to update the SQL statement, using where clause... JDBC Prepared Statement Update   ... Prepared Statement Update. The code include a class Jdbc Prepared Statement
using switch case
using switch case  Define a class MENU to perform the following operation depending upon the users choice using switch case 1)print square root...){ case 1: System.out.println("Square Root of "+num
HQL Update Statement to update database table
HQL Update Statement to update database table HQL's update query statement is used to update the values of database rows. Though HQL is similar to SQL...()); } } } Output of UPDATE Statement: log4j:WARN No appenders could
Statement Batch Update
Statement Batch Update       In this section we are going to learn about the batch update... are added in the Statement object and update the records of database simultaneously
i need to replace this if statement code with switch case code
i need to replace this if statement code with switch case code   i need to replace this code with switch case for(int i=0;i<100;i++){ if((i...){ switch(i/j){ case 3: System.out.println ("java
JDBC Batch Example With SQL Update Statement
JDBC Batch Example With SQL Update Statement: In this tutorial, we are discuss about update SQL statement with the jdbc batch. Now we will create a java...;); Now we will create Statement object by using createStatement() method
Case-insensitive ordering using Hibernate Criteria.
Case-insensitive ordering using Hibernate Criteria.  What is Case-insensitive ordering in Hibernate Criteria
JDBC Batch SQL Update Statement Example With Return Number of Effected Rows
JDBC Batch SQL Update Statement Example With Return Number of Effected Rows: In this example, we are discuss about update statement with return number... represents the update count for the respective update statement. First we
Case-insensitive equals using Hibernate Criteria.
Case-insensitive equals using Hibernate Criteria.  How to use Case-insensitive equals with Hibernate Criteria?   The Case Insensitive ignores the case of the latter. It Selects all the records of the table related
how do i update my database with the help of update syntax in html <text/javascript>? How to write 'where' statement in this?
how do i update my database with the help of update syntax in html ? How to write 'where' statement in this?  var sqlmek="update into Student_info...'); alert('Press OK to Update your Records Successfully
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.  String sql = "UPDATE emp_details SET empEname = ?, emailId = ?, guid =?, proximityCard =?, managerEmailId = ?, reviewerEmailId
Update value of database using hibernate.
Update value of database using hibernate.  How to update value of database using hibernate?   Hibernate provides facility to update... this by setting the value and calling the update method. session.update(employee
update excel sheet using jsp::
update excel sheet using jsp::   Hi Sir,... I have a excel... given excel sheet and display it into another excel sheet using jsp" i am using 'session' to get the empid from one page to another jsp
Prepared Statement With Batch Update
Prepared Statement With Batch Update   ... PreparedStatementBatchUpdate Prepared Statement Batch Update Example! Added... with BatchUpdate and we are going to provide an example that performs batch update
Case-sensitive equals using Hibernate Criteria.
Case-sensitive equals using Hibernate Criteria.  How to check for case sensitive equals in Hibernate criteria?   package net.roseindia.main; import java.util.*; import net.roseindia.table.Employee; import
Writing a loop statement using Netbean
Writing a loop statement using Netbean  Write a loop program using NetBeans.   Java Loops class Loops{ public static void main(String[] args){ int sum=0; for(int i=1;i<=10;i
how to update table using inner joins
how to update table using inner joins  how to update table using inner joins
Using insert update and delete in the same servlet
Using insert update and delete in the same servlet  How to write insert, update and delete coding in the same servlet
Advertisements
 

 

 

DMCA.com