Showing posts with label full join. Show all posts
Showing posts with label full join. Show all posts

Monday, January 1, 2018

Update A Joined Table Mysql

I want to update a table in a statement that has several joins.
The multi-table UPDATE syntax in MySQL is like blew as sample

UPDATE tableA a
JOIN tableB b
   ON a.a_id = b.a_id
JOIN tableC c
   ON b.b_id = c.b_id
SET b.val = a.val+c.val
WHERE a.val > 10
    AND c.val > 10;


Sunday, June 21, 2015

How to do FULL JOIN in MYSQL

MYSQL don't support FULL JOIN. But there is a good trick to do this in easy way.
Follow this code and it's simple.

with two tables t1,t2:
SELECT * FROM  t1  LEFT   JOIN  t2  ON  t1.id=t2.id
UNION
SELECT * FROM  t1 RIGHT  JOIN t2  ON  t1.id=t2.id

See very simple to do!!!!!!!!!!!! 

Total Pageviews