select a.*, b.*
from a
join b on a.b_id=b.id
where b.whatever_id in(10,15,20)
select a.*, b.*
from a
join b on a.b_id=b.id and b.whatever_id in(10,15,20)
$select = 'select * from watches where 1=1';
$binds = [];
if(!empty($from)) {
$select .= ' and from>=?';
$binds[] = $from;
}
if(!empty($before)) {
$select .= ' and before<=?';
$binds[] = $before;
}
$stmt = $this->_instance->prepare($sql);
$stmt->execute($binds);
$items = $stmt->fetchAll(PDO::FETCH_ASSOC);