Roman Carlo Yap
Roman Carlo Yap

Reputation: 21

basic query on associative arrays

How to do I query this in?

Graph is working on this query

$dataPoints = array();

$result = mysqli_query($conn, "SELECT * FROM service_booking GROUP BY service_id");

while($row = mysqli_fetch_array($result))
{        
    $point = array("label" => $row['service_id'] , "y" => $row['booking_id']);

    array_push($dataPoints, $point);        
}

but I want the "label" $row['service_id'] display as a ['services'] coming from a different parent table.

  services (tbl1)                            service_booking (tbl2) 
 services || service_id                     service_id ||  booking id

Upvotes: 2

Views: 86

Answers (1)

Barmar
Barmar

Reputation: 780889

Join the tables

SELECT b.*, s.services
FROM service_booking AS b
JOIN services AS s ON s.service_id = b.service_id

Upvotes: 1

Related Questions