Here I have 2 tables
- trips : trip_id, customer_id, trip_status
- customers : customer_id, customer_name, customer_phone
Every trip has one customer and i joined the both table using inner join
I tried this way
SELECT * from trips JOIN customers ON trips.customer_id = customers.customer_id limit 1
This gives me a single row with both table data
i need something like
{
"trip_id": "12",
"trip_status": "CLOSED",
"customer": {
"customer_name": "A",
"customer_phone": "0123335566",
"customer_id": "1"
}
}
I need the customer table inside another object.
Thanks in advance