Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql update field from one table to another

UPDATE MY_TABLE AS t1
INNER JOIN MY_OTHER_TABLE AS t2 ON t1.COLID = t2.COLID
SET t1.COL1 = t2.COL1, t1.COL2 = t2.COL2
WHERE t1.COL3 = 'OK';
Comment

mysql update table from select on another table

UPDATE TableB 
SET TableB.value = (
    SELECT TableA.value 
    FROM TableA
    WHERE TableA.name = TableB.name
);
Comment

mysql update table from another table

UPDATE tableB
INNER JOIN tableA ON tableB.name = tableA.name
SET tableB.value = IF(tableA.value > 0, tableA.value, tableB.value)
WHERE tableA.name = 'Joe'
Comment

mysql update column with value from another table

UPDATE tableB
INNER JOIN tableA ON tableB.name = tableA.name
SET tableB.value = IF(tableA.value > 0, tableA.value, tableB.value)
WHERE tableA.name = 'Joe'
Comment

PREVIOUS NEXT
Code Example
Sql :: create unique index postgres 
Sql :: sql in sublime 
Sql :: replace all numbers in mysql 
Sql :: postgresql update between 2 tables 
Sql :: docker open terminal mysql server 
Sql :: media sql 
Sql :: select all except one column sql 
Sql :: mysql start command 
Sql :: sqlite3 read only 
Sql :: create index concurrently postgres 
Sql :: sql server pagination limit 
Sql :: mysql order 
Sql :: mysql query bulk insert 
Sql :: sql offset 
Sql :: insert query return id mysql 
Sql :: execute mysql file 
Sql :: oracle trigger after connect 
Sql :: how to get nearest location in mysql with latitude and longitude 
Sql :: CONCAT_WS() concat function we can use for adds two or more expressions together with a separator or delimeter. 
Sql :: sql add two values together 
Sql :: sql select second max 
Sql :: postgres set column based on another column 
Sql :: login to mysql database 
Sql :: count column of tables psql 
Sql :: add column text sql after column 
Sql :: spring where to put the data sql 
Sql :: ascending order mysql 
Sql :: postgres show databases 
Sql :: windows services sql 
Sql :: how to copy data in sql 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =