0
Can someone help me? I have the following problem: I have 2 tables and in these 2 tables I have the names, and in the course table I have nome
and in the category table I also have the field nome
. My question is this: how do I do it in the PHP
? I’m trying to do it like this:
$sql = mysqli_query($mysqli, "SELECT cur.nome, cat.nome FROM cursos cur INNER JOIN categorias cat ON cur.id_curso = cat.id WHERE cat.id = '$id_categoria'");
$row = mysqli_fetch_array($sql);
After that, I don’t know how I select either the course name or the category name. Could anyone help me?
This has nothing to do with php, this is sql
– MarceloBoni
You can set an alias for the fields
cur.nome, cat.nome
thus:cur.nome AS nomeTabelaX, cat.nome AS nomeTabelaY
– MarceloBoni
would look something like this?
SELECT cur.nome AS curso, cat.nome AS categoria FROM...
?– Gustavo_dev
intendi intao thank you for the reply
– Gustavo_dev
related also: http://answall.com/questions/65624/dados-countercountercountercom-inner-join-utilizando-pdo
– MarceloBoni