0

There are two tables one transaction and other customer. I am getting multiple rows of customerid and service time, but I want customer name (which is in customer table) and service time. So I tried below query which is not working.

select name,service_time from CUSTOMER,TRANSACTION
WHERE id IN 
(
    select customer_id,service_time from TRANSACTION 
    where  service_date='$date' and employee_id='$employee_id'
);
Bill Woodger
  • 12,968
  • 4
  • 38
  • 47
rohan
  • 43
  • 11

1 Answers1

0

Use JOIN

SELECT c.name, t.service_time 
  FROM CUSTOMER AS c
  JOIN TRANSACTION AS t ON t.customer_id = c.id
 WHERE t.service_date = '$date' 
   AND employee_id = '$employee_id'

Refer to:

Community
  • 1
  • 1
Ravinder Reddy
  • 23,692
  • 6
  • 52
  • 82