So my scenario is, in a single query I have to select data from 4 tables. There is one to many relationships between booking and booking details and each booking detail has one test associated to it.
Query I wrote:
$fetch_test = "SELECT br.id, b.bookingno, p.firstname, p.lastname, t.title
from booking_rider br, bookings b, patients p, booking_details d, tests t
where br.bid = b.id and d.bid = b.id and t.id = d.tid and b.uid = p.id and br.rid = 0 group by d.bid " ;
Basically in one booking there are many tests.. This query is returning me just one test title.
I want it a json object of all test titles inside the result. How to achieve it?