Home Answers Viewqa SQL using case in update statement

 
 


rudranarayana samal
using case in update statement
2 Answer(s)      2 years and 6 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;

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 Pages:
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
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
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
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
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
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
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
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
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
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
update
update  how can i update multiple records in database using jsp ,servlet and jdbc based on selection of checkbox in jsp
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
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
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
switch statement
switch statement   i want to write a java program that computes Fibonacci,factorial,string reversal and ackerman using switch case to run as a single program
Switch Statement
switch case statement. The program displays the name of the days according to user...Switch Statement  How we can use switch case in java program ?   Note:-Switch case provides built-in multiway decision statement.It
The Switch statement
. Here is the general form of switch statement: switch (expression){ case 1... of multiple case statements and an optional default statement.  The execution... with the next case after executing the first statement.  Here is an example
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
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
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
if Statement - Overview
with if. [The other 1% of the decisions use the switch/case statement.] General Forms The if statement has this form: Do these statements before...Java Notesif Statement - Overview Purpose The purpose of the if statement
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
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
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.
JSP Servlet update patient data - JSP-Servlet
JSP Servlet update patient data  Hi Friend, I'm attaching my... not working in my case, perhaps of the following things which I can explain to you so... patient_id='"+id+"' and dov='"+date+"'; if i use any other statement obviously
Update / Edit data
Update / Edit data  Hello, i want to create a page to edit or update... field that i have prepared under the submit button. btw, im using jsp. thank you..., that data will get shown in another page and allow the user to update
Switch Statement in java 7
executed. Example : In this example we are using switch -case statement to print the day of week. If day value is 1 then case 1 will execute its statement... default at the last of all case statement which will execute when day value
JDBC: Update Records Example
records of the table using JDBC API. Update Records : Update record is most... for such situation you can use update statement to update particular value of record...("Update Records Example..."); Connection con = null; Statement
JDBC: Batch Update Example
update process - Create object of Statement using createStatement() methods... update of records using JDBC API. Batch Update : When you want to update... concept. We can update multiple rows using single connection in batch update
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
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%3)==0) system.out.println("java"); if((i%5)==0) system.out.println("technology
SQL STATEMENT in JDBC in NETBEANS IDE
SQL STATEMENT in JDBC in NETBEANS IDE  Iam using NETBEANS IDE. Iam developing a bank application. Using JDBC in SERVLETS For the withdraw function, "bal" and "ano" are user inputs when i wrote like, st.executeQuery("UPDATE
update query
update query  using oops concept in php.. How to update the data from databse ? with program example
JDBC Prepared Statement Insert
JDBC Prepared Statement Insert   ... Statement Insert. In this Tutorial  the code describe the include a class... value into the employees table. prepare Statement ( ) - Unlike create
Update value
Update value  How to update value of database using hibernate ?   Hi Samar, With the help of this code, you will see how can update database using hibernate. package net.roseindia.DAO; import
Case-insensitive ordering using Hibernate Criteria.
Case-insensitive ordering using Hibernate Criteria.  What is Case-insensitive ordering in Hibernate Criteria
Break Statement in java 7
of your program by using break statement. The break statement breaks the flow... use break at the end of each case. There is two kinds of break statement... break statement.."); break; // using break statement to break for loop
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 - JDBC
in a variable suppose num = 10. Step2: Execute update statement for example reUpdate Emp... is what I used to update normally. It works. Please assist me. Thanks...("jdbc:odbc:Biu"); stat = con.prepareStatement("Update Biu SET itemcode
Update Records in Database
the record  from table country. The Update statement is used to update the table... Update Records in Database       The Update Records in database is used to modify
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
data update
the data and edit it based on subjectcode(varchar)this should be done using jsp... edit/update data and saved them into that table again
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
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
Jdbc Insert Statement
the INSERT statement using execute Update ( ).The executeQuery ( ) return you the retrieved record set  from a table using select statement...; Add a row to a existing table using insert statement in JDBC
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
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.