将标记为非活动的员工分配给管理员作为活动状态

时间:2017-02-28 21:50:02

标签: mysql sql

CREATE DATABASE IF NOT EXISTS empdb;
 
-- create tables
CREATE TABLE emp_status (
   Id INT(11) DEFAULT NULL AUTO_INCREMENT, status VARCHAR(255),
    PRIMARY KEY (id)
);
 
CREATE TABLE employees (
    emp_id INT(11) NOT NULL AUTO_INCREMENT,
    emp_name VARCHAR(255) NOT NULL,
    Id INT(11) DEFAULT NULL,
    PRIMARY KEY (emp_id),
    CONSTRAINT fk_id FOREIGN KEY (id)
        REFERENCES emp_status (id)
);


-- insert data for emp_status table
INSERT INTO emp_status(status) VALUES ('active');


-- insert data for employees table
INSERT INTO employees(emp_name,status)      
VALUES('Mary Doe', 'inactive'),
      ('Cindy  'inactive'),
      ('Sue Greenspan',  'inactive');

0 个答案:

没有答案