0
Good afternoon, you guys.
I have a small question: When registering a customer (with an address field (fk)) the correct way is something like this, or has a better way?
INSERT INTO endereco(logradouro, numero, bairro, cidade)
VALUES (:logradouro, :numero, :bairro, :cidade)");
Get the ID where the address matches what was previously entered;
SELECT id FROM endereco
WHERE logradouro = :logradouro AND numero = :numero
AND bairro = :bairro AND cidade = :cidade;
Insert the recovered ID into SELECT in FK(id_do_select);
INSERT INTO usuario(login, senha, nome, endereco_id)
VALUES (:login, :senha, :nome, :id_do_select)");
Have any way to enter the address id in the client’s FK without first making a SELECT?
vlw.
Address has primary key?
– novic