0
Has 3 tables
On the table
entrada
has the data:id_entrada
,id_empresa
,id_categoria
and id_subcategory.On the table
cat_entradas
have:id_categoria
andcategoria
.And on the table
sub_cate_entrada
have:id_subcategoria
andsubcategoria
.
I already got the two ids (id_category and id_subcategory) in the input table.
Now, I need to take the category and the subcategory in their respective tables. Can I do this in an SQL command only, or I will have to do 2, one for each table?
<?php
$pdo = conectar();
$this->dataConta=$pdo->prepare("SELECT categoria, subcategoria FROM entrada WHERE id_entrada=:id_entrada AND id_empresa=:id_empresa");
$this->dataConta->bindValue(":id_entrada", 30);
$this->dataConta->bindValue(":id_empresa", 1);
$this->dataConta->execute();
$res = $this->dataConta->fetch(PDO::FETCH_ASSOC);
echo $res['categoria']." - ". $res['subcategoria'];
$pdo = null;
You can, but it’s hard to understand exactly what you want. If you have an example of data, a couple of rows for each table, plus a couple of rows for the results you already have and want, it helps a lot to answer. The queries you’ve already built also help.
– fbiazi
@fbiazi, see if the code I put in, help.
– GustavoSevero