I am looking for the best way to perform the query below as a Laravel 4.2 query. I am struggling on the where clause which has a sub query to work.
What my query is doing:
I have a parent table with a 1-many child table. I want to get a list of all the child records associated to the parent record only knowing a current child record.
select child.id, child.jobNumber
from child
where child.parentId = (select child.parentId from child where child.id = 2)
order by child.jobNumber, child.id
Something like:
$query = DB::table('child');
$query->select(array('child.id','child.jobNumber'));
$query->orderBy('child.jobNumber');
$query->orderBy('child.id');
// how do I do my where clause?
$list = $query->get();