Batch Update
The MySQL UPDATE statement is simple, updating a field of data that is generally written like this:
Copy Code code as follows:
UPDATE mytable SET myfield = ' value ' WHERE Other_field = ' other_value ';
If you update the same value in
WHERE Other_field (' other_values ')
If the Where condition query out the ID of the record is not within the case range, MyField will be set to null.
If you update multiple values, you need to modify them only slightly:
UPDATE mytable
SET myfield1 = case ID if
1 THEN ' Myvalue11 ' when
2 THEN ' Myvalue12 ' when
3 THEN ' Myva Lue13 ' End
,
myf
Cases
The code is as follows
Copy Code
SELECT cat. ' Name ', class. ' Title 'From ' Cat ', ' class 'WHERE cat. ' id ' = class. ' Cat 'and cat. ' ID ' =2LIMIT 0, 30DELETE cat, class from Cat, Class WHERE cat. ' ID ' =class. ' Cat ' and Cat. ' ID ' =1
Multiple table Updatesin MySQL 3.23, you can use LIMIT # to ensure that only the given number of record rows is changed.
How can I locate multiple mysql tables in which the content is sorted by the last update time? how can I locate multiple mysql tables in which the content is sorted by the last update time?
The four fields are the same, and only t
Label:MySQL statement: Batch update of different values for multiple records MySQL UPDATE statement is simple, update a field of the data, generally write:
1
UPDATEmytable SETmyfield = ‘value‘WHERE other_field = ‘other_value‘;
If you
We will use join subqueries to update multiple tables using one MySQL statement. Let's take a look at the implementation method.
MySQL itself supports updating multiple tables with one update statement. Sometimes this is a very us
1, MySQL multiple table association Delete use alias, TBLWENHQ is the real table name, A is TBLWENHQ alias, B is another table name
The code is as follows
Copy Code
DELETE A from TBLWENHQ a,b where a.id=b.id
2. When using MySQL for the delete from operation, an error occurs if the FROM clause of the subquery and the
when 3 Then 5 ENDWHEREIdinch(1,2,3)This SQL means, update the Display_order field, if id=1 the value of Display_order is 3, if id=2 Display_order value is 4, if id=3 then Display_order value is 5. That is, the conditional statements are written together. The where section here does not affect the execution of the code, but it improves the efficiency of SQL execution.Make sure that the SQL statement executes only the number of rows that ne
MySQL multiple tables How to find the contents of the content by the last update time arrangement
Field four tables are the same, only the content is different
Table name: AAA,BBB,CCC,DDD Four tables
Table field: Title,classid,userid,newstime,classname,images
I now want to put four independent tables without any association, to find out the last
How can I locate multiple mysql tables in which the content is sorted by the last update time mysql nbsp; how can I locate multiple tables in which the content is sorted by the last update time and the fields are the same, only t
The MySQL UPDATE statement is simple, updating one field of multiple data with the same value, which is generally the case:UPDATE table_name SET field = ' value ' WHERE condition;To update multiple data to different values, you can:foreach ($display _orderas$id$ordinal) {
Tags: mysql optimized storageTypically, we use the following SQL statement to update field values:Copy CodeThe code is as follows:UPDATE mytable SET myfield= ' value ' WHERE other_field= ' other_value ';But what do you do if you want to update multiple rows of data, and each field value is different for each row of rec
MySQL Update multi-table example explanation
Let's take a look at the following examples:
Example one:
Update TAB1 set TAB1. Product size = (select TAB2. Product size from TAB2 where tab2. Product color = tab1. Product color) where TABL1. Product color in (select TAB2. Product Colors From TAB2)
Continue with the following examples:
Label:The MySQL UPDATE statement is simple, updating one field of multiple data with the same value, which is generally the case: UPDATE table_name SET field = ' value ' WHERE condition; To update multiple data to different values
MySQL itself supports an UPDATE statement to update multiple tables, which is sometimes a very useful feature.
multiple-table syntax
UPDATE [low_priority] [IGNORE] Table_referencesSET col_name1={expr1| DEFAULT} [, col_name2={exp
We have two tables, one for the product table, one for the products, the price for the product, and one for the Productprice table, which we want to update the Price field in the Productprice table to 80% of the price field in the prices table.In MySQL we have several means to do this, one is update table1 t1, table2 ts ... The way:Copy CodeThe code is as follows
The SQL statement is: SELECT * FROM table1 where ' text ' like CONCAT ('% ', (select name from table2 where ID =3), '% ');UPDATE ecs_region a,nation b SET a.code = B.code where b.province like concat ('% ', a.region_name, '% ');UPDATE ecs_region a,nation b SET a.code = B.code where b.city like concat ('% ', a.region_name, '% ');UPDATE ecs_region a,nation b SET a
When multiple timestamp are present in a table and one is set to Current_timestamp, you often encounter#1293-incorrect table definition; There can is only onetimestamp column with Current_timestamp in DEFAULT or on UpdateclauseThe reason is that when you set the timestamp to on Updatecurrent_timestamp, the other timestamp fields need to explicitly set the default valueBut if you have two timestamp fields, but only the first one is set to Current_times
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.