I have a query sql like the following may be a bit complex, I am a bit of trouble to convert into a for framework laravel. Please help for everything with framework laravel query results. My problem here is, I do not know how to create a sub select query to laravel framework. Thanks guys.
select lin_users.id,
lin_users.status_employee_id,
lin_users.username,
lin_users.email,
lin_employee_attributes.unit_code,
lin_employee_attributes.position_code,
lin_employee_attributes.begin_date,
lin_employee_attributes.end_date,
(select contact_id from lin_contacts where person_id = lin_people.id AND contact_type='Work Telephone') as cell_number,
(select contact_id from lin_contacts where person_id = lin_people.id AND contact_type='Mobile') as phone_number,
(select contact_id from lin_contacts where person_id = lin_people.id AND contact_type='Email') as email
from lin_users
INNER JOIN lin_status_employees
ON lin_users.status_employee_id = lin_status_employees.id
INNER JOIN lin_people
ON lin_status_employees.person_id = lin_people.id
INNER JOIN lin_employee_attributes
ON lin_users.status_employee_id = lin_employee_attributes.status_employee_id
INNER JOIN lin_contacts
ON lin_people.id = lin_contacts.person_id
WHERE lin_employee_attributes.begin_date = '2016-09-23'
and lin_employee_attributes.end_date = '2016-10-02'
GROUP BY lin_users.id, lin_employee_attributes.unit_code, lin_employee_attributes.position_code, lin_employee_attributes.begin_date, lin_employee_attributes.end_date, lin_people.id;
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire