I have two tables with the following structure:
tblA:
+----------+---------------+ | id (int) | name (string) | +----------+---------------+ | 1 | a | | 2 | b | | 3 | c | +----------+---------------+
tblB:
+----------+---------------+-------------+ | id (int) | name (string) | aid(string) | +----------+---------------+-------------+ | 1 | x | '1,2' | | 2 | y | '2,' | | 3 | z | '1,3' | +----------+---------------+-------------+
$a = $this::$db->prepare('SELECT * FROM tblB WHERE id= :id LIMIT 1');
$a->bindValue(':id', $ID, PDO::PARAM_INT);
$a->execute();
$r = $a->fetch(pdo::FETCH_ASSOC);
if ($a->rowCount() > 0){
$bInf = $r['id'] . '|*|' .
$r['name'] . '|*|' .
$r['aid'] . '|**|';
$b = $this::$db->prepare('SELECT id,name FROM tblA WHERE FIND_IN_SET(id,:ids)');
$b->bindValue(':ids', $r['aid']);
$b->execute();
$rs = $b->fetchAll(pdo::FETCH_ASSOC);
if ($b->rowCount() > 0)
{
foreach ($rs as $srow => $srval)
$aInf .= $srval['id'] . '[|]' .
$srval['name'] . '[#]' ;
} else
$aInf = ' ';
$aInf.= '|***|' . $bInf;
}
}
i need to query from tblA and tblB as above sample, but second query dont return any records.
i also tried 'IN' operator but dont worked too...
pls help me...