[mysql] dosent work
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- DROP DATABASE IF EXISTS Final;
- CREATE DATABASE Final;
- USE Final;
- SET SQL_SAFE_UPDATES = 0;
- DROP TABLE IF EXISTS tableA;
- DROP TABLE IF EXISTS tableB;
- CREATE TABLE tableA (
- id INT PRIMARY KEY AUTO_INCREMENT,
- name VARCHAR(5),
- number INT
- );
- CREATE TABLE tableB (
- id INT PRIMARY KEY AUTO_INCREMENT,
- name VARCHAR(5),
- number INT
- );
- INSERT INTO tableA(name, number) VALUES("Joe", 22);
- INSERT INTO tableA(name, number) VALUES("Derk", 30);
- INSERT INTO tableB(name, number) VALUES("Judah", 23);
- INSERT INTO tableB(name, number) VALUES("Mary", 26);
- UPDATE tableB
- INNER JOIN tableA ON tableB.name = tableA.name
- SET tableB.number = IF(tableA.number > 0, tableA.number, tableB.number)
- WHERE tableA.name = 'Joe';
- SELECT * FROM tableA;
- SELECT * FROM tableB;
Editor
You can edit this paste and save as new: