title: How to use merge function in MySQL?
body: <p>I'm still new to sql query.</p>
  
  <p>My table query is as below:</p>
  
  <pre><code>CREATE TABLE Department (
      D#      NUMBER(5)   NOT NULL, /* Department number      */
      DName       VARCHAR2(30)    NOT NULL, /* Department name        */
      Manager#    CHAR(5)     NOT NULL, /* Department manager number  */
      MSDate      DATE,             /* Manager start date         */
      CONSTRAINT Department_PK PRIMARY KEY(D#),
      CONSTRAINT Department_CK UNIQUE(DName)
  );
  INSERT INTO Department VALUES (1, 'SALES', '00110', TO_DATE('02/01/2012', 'DD/MM/YYYY'));
  INSERT INTO Department VALUES (2, 'ACCOUNTING', '00120', TO_DATE('30/10/2010', 'DD/MM/YYYY'));
  INSERT INTO Department VALUES (3, 'GAMES', '00150', TO_DATE('01/03/2008', 'DD/MM/YYYY'));
  INSERT INTO Department VALUES (4, 'HUMAN RESOURCES', '00200', TO_DATE('02/01/2013', 'DD/MM/YYYY'));
  INSERT INTO Department VALUES (5, 'SPORTS', '00250', TO_DATE('10/05/2010', 'DD/MM/YYYY'));
  </code></pre>
  
  <p>I' m going to implement sql query like the department “SPORTS” will be merged into the department “GAMES”. The manager of the department “GAMES” is still the manager of that department. The employees that worked in the department “SPORTS” stay in the same locations. </p>
  
  <pre><code>MERGE INTO department d
  USING (
    SELECT Manager#,MSDate
    FROM department d
  ON (d.D# = 'GAMES')
  WHEN MATCHED THEN
    UPDATE SET d.Manager# = d.Manager#
  WHEN NOT MATCHED THEN
    ...
  </code></pre>
  
  <p>*</p>
  
  <p>Somehow i had try to use this query to try out but no luck it no working :( I very appreciate for the help if any.</p>