3
I have a problem, I have two tables that are related from the foreign key and the primary key like this:
CREATE TABLE IF NOT EXISTS cargo(
id INT AUTO_INCREMENT NOT NULL,
nome_cargo varchar(50) not null, "supervisor,gerente, etc..."
salario_cargo DECIMAL NOT NULL,
tipo_cargo VARCHAR(11) NOT NULL, "administrador ou funcionario comum"
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS funcionario(
id INT AUTO_INCREMENT NOT NULL,
rg VARCHAR(10) NOT NULL,
cpf VARCHAR(11) NOT NULL,
email VARCHAR(255) NOT NULL,
senha VARCHAR(50) NOT NULL,
nome VARCHAR(50) NOT NULL,
id_cargo INTEGER NOT NULL,
PRIMARY KEY (id)
);
ALTER TABLE funcionario ADD foreign key (id_cargo) REFERENCES cargo (id);
Every position has an id and the id_position of the employee table serves to identify what the position of this employee, however, I do not know how to select from the employee’s email I can know if he is administrator or common employee, I tried some codes but none worked, someone helps me
Man, thank you very much msm, the way I needed to... vlw
– Trufa