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



Home Answers Viewqa SQL using case in update statement

Have Programming Question? Ask it here!
 
 
 


rudranarayana samal
using case in update statement
2 Answer(s)      3 years and 9 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
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
Advertisements
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
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
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
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
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
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
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
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
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
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
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
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
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
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
update a particular of mysql table using servlet
update a particular of mysql table using servlet  how to update a particular column for the entire table by taking requests from html form and update the particular column with out affecting other attribute values in the tuple
update database using two queries at a time
update database using two queries at a time  String sql="insert... can execute two queries with two different Statement object in the following way. Another thing, you have executed same query twice in your code. Statement st1
PreparedStatement using batch update - Java Beginners
PreparedStatement using batch update  How to execute different preparedStatement object using batch update(Java) Pls explain with the code... + db, user, pass); pst = con.prepareStatement("update data set address
Case-insensitive search using Hibernate Query Language(HQL).
Case-insensitive search using Hibernate Query Language(HQL).  What is Case-insensitive search using Hibernate Query Language
Switch case in java
. A statement in switch is labeled with one or more case or default. If we talk about...Switch case in java In this section we will learn about switch case in java..., and java, switch case is used . switch  is a selection control mechanism used
update
update  how can i update multiple records in database using jsp ,servlet and jdbc based on selection of checkbox in jsp
Write a java program to display the season given the month using switch case
Write a java program to display the season given the month using switch case  Write a java program to display the season given the month using switch case
Insert Date using Statement - Development process
Insert Date using Statement   Hi, plz send me code for Storing system date using statement instead of preparedstatement. Thanks Prakash  Hi Friend, Try the following code: Thanks
MySQL Case
MySQL Case       This example illustrates how to use case statement in MySQL database. MySQL Case... case statement. It performs the work as programming type.  The CASE
PHP MySQL Update
PHP MySQL Update       In SQL, Update is another statement which is used to update any record of a table. This command is useful when we need to update any existing value, which could
Read Excel data using JSP and update MySQL databse
Read Excel data using JSP and update MySQL databse  HOw to read excel data using JSP and update MySQl database
Case Java Keyword
statement in java program. In other word Case is a java keyword... programming statement case block will not have the implicit ending point. At java statement every time break statement will typically be used at the end of each case
update
update  Predict and justify the output of the following code snippet written by the developer to update the Status table: String str = "UPDATE m...://localhost:3306/roseindia", "root", "root"); String str = "UPDATE Status SET
MySQL Case In Where Clause
;  This example illustrates how to use case statement where clause... conditional construction then you can use MySQL case statement. It performs the work...; Output: Using MySQL 'case' and 'where' clause: SELECT daysName
Read data from excel file and update database using jsp
Read data from excel file and update database using jsp  read data from excel file and update database using jsp Hi, I am using a MySQL database... upload excel file and update database using JSP ? Thanks in Advance
to write an SQL query using insert statement
to write an SQL query using insert statement  I need to write an sql query for the below using InSERT command.pls help. Insert 5-star ratings by James Cameron for all movies in the database. Leave the review date as NULL
Switch Case in Java
after the case statements. Otherwise, the statements after the default statement... A statement in the switch block can be labeled with one or more case or default labels... case will take place. Example of Switch Statement in Java: import java.io.
JDBC: Select Records using Prepared Statement
JDBC: Select Records using Prepared Statement In this section, you will learn how to retrieve records of table using Prepared Statement. Select Records   : Prepared Statement is precompiled SQL Statements which are stored
for statement
for statement  for(int i=0;i<5;i++); { system.out.println("The value of i is :"+i); } if i end for statement what will be the output   got the answer.. it displays only the last iteration that is "The value of i
 

 

 

DMCA.com