[英]Selecting multiple rows in a Select statement using PDO
I have two tables, I want to select from the first the ID of Salles for each Responsible (he may have many -> array()) . 我有两个表,我想从每个表中选择每个负责人的Salles的ID(他可能有很多-> array())。
so I want to select all the salles this responsible have, and I did this statement (which returns an empty array and I am unsure of why): 因此,我想选择此负责人拥有的所有职能部门,然后执行此语句(该语句返回一个空数组,但我不确定原因):
$sels = $db->prepare("SELECT salle FROM salleresp WHERE resp = :resp");
$sels->bindParam(':resp',$rsb['matricule']);
$sels->execute();
$rss = $sels->fetchAll(PDO::FETCH_ASSOC);
$questionmarks = str_repeat("?,", count($rss)-1) . "?";
$selectSalle1 = $db->prepare("SELECT * FROM salle WHERE salleId IN ($questionmarks) ");
$selectSalle1->execute($rss);
$showAll=$selectSalle1->fetchAll(PDO::FETCH_ASSOC);
when I do: 当我做:
print_r($showAll);
it return an empty array: 它返回一个空数组:
array()
Any suggestions please? 有什么建议吗?
SELECT * FROM salle WHERE salleId IN (SELECT salle FROM salleresp WHERE resp = :resp)
or 要么
SELECT * FROM salle left join salleresp on (salle.salleId = salleresp.salle)
WHERE resp = :resp)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.