mysql - PHP Join Query for Three Table When There is No Direct Common Column? -


i have 3 tables in first 2 tables have common column match record, , 2nd , third table have common column there no direct matching column in first , third table. how shall write join query ?

  1. table1(order) column names 'order_id', 'patient_id', 'total', 'discount'
  2. table2 (order_details) column names 'order_details_id', 'order_id', 'test_id', 'result'
  3. table3(tests) column names 'test_id', 'test_name', 'test_normal_value'

i hope helps

select * `order` left join `order_details` on `order`.`order_id` = `order_details`.`order_id` left join `tests` on `order_details`.`test_id` = `test`.`test_id` 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -