0
I have a table person who owns the fields name, city and phone and time_id. I also have another table with a team name and in it I have a field called meu_time, as I can do an INNER JOIN to register the team in this table time but in the table person in the field time_id receive the corresponding id?
$sql = "INSERT INTO pessoa (nome, cidade, telefone) VALUES(:nome, :cidade, :telefone)";
$stmt = Parent::__construct()->prepare($sql);
$stmt->bindParam(':nome', $nome);
$stmt->bindParam(':cidade', $cidade);
$stmt->bindParam(':telefone', $telefone);
$stmt->execute()
Just a question because it is not clear in the question. You are wanting to use
INNER JOIN
in a commandINSERT
?– Pagotti
@Pagotti, I believe it is an Insert in two tables
– Wees Smith
axo que ele quer buscar um informação em uma tabela e usar ela... but I think he’ll have to make a select
– Willian
Exactly, I’ll try to explain it better. I have a form and for it register in the bank the name of the person, city, phone and his team, but I did not want to leave the team in the same table of the person, this is because other people can have the same team, then it would be more organized if the tables were separate
– Otavio Fagundes
You can put the structure of the two tables in the question to see if you can use the
LAST_INSERT_ID
?– Pagotti
The team I type to register, but in case it already exists I did not want to create another registration with the same team name, in case there is I just wanted to use what is already there
– Otavio Fagundes
The table is called main is called user, then inside it I have the table person and the table time
– Otavio Fagundes
the team is already registered?
– Wees Smith
The team I will register together when registering the user, but I did not want to register the team in the same person field
– Otavio Fagundes
is that it gets more organized separately and I’ll have greater control over it
– Otavio Fagundes
Updates your question by placing these details and the structure of the tables involved.
– Pagotti