php - MySQL LIMIT results with INNER JOIN with more than 2 tables -
i have database user allowed have more 1 email address. want query database instances of job customer. each job returning twice, 1 each email.
here query:
select customers.first_name, customers.last_name, emails.email, services.title, services.description, jobs.status, jobs.job_id customers inner join emails on customers.user_id=emails.user_id inner join jobs on customers.user_id=jobs.customer_id inner join services on jobs.service_id=services.service_id;
it returning this:
i want return results first email only. row should not duplicated each email address user has on file.
how can done?
you can use group by
on sql unique column value follows.
select customers.first_name, customers.last_name, emails.email, services.title, services.description, jobs.status customers inner join emails on customers.user_id=emails.user_id inner join jobs on customers.user_id=jobs.customer_id inner join services on jobs.service_id=services.service_id; group jobs.job_id;
Comments
Post a Comment