Question: I have one Json file and i need to extract the "tempm" I have try using different forms but couldn't never get only that value.
[![enter image description here](https://i.stack.imgur.com/Gkk9F.png)](https://i.stack.imgur.com/Gkk9F.png)[1](https://i.stack.imgur.com/Gkk9F.png)][1](https://i.stack.imgur.com/Gkk9F.png)

```
$history1 = ("http://link_to_my_api");
echo $history1;
$json_string = file_get_contents($history1);
$parsed_json = json_decode($json_string);
$location = $parsed_json->{'history'}->{'observations'};

var_dump( $location[0]);

```

Answer: 
To know whether a client rents all the car from a particular firm, you need to know how many cars owned by the firm and how many cars rented from the firm by the client.
To know how many cars owned by the firm, you can get that by this query:

```
SELECT      Firms, COUNT(*) AS NUM_OF_CAR
FROM        FirmTable
GROUP BY    Firms

```

And to know how many cars rented from the firm by the client, you can get by this query:

```
SELECT      Client, Firms, COUNT(*) AS NUM_OF_CAR
FROM        FirmTable a
INNER JOIN  ClientTable b ON a.Car = b.Car
GROUP BY    Client, Firms

```

And now you need to get the client that rents all the car, meaning that the NUM\_OF\_CAR from the first query and the second query must match for the respective firm.
Combining both queries above, you can use:

```
SELECT      DISTINCT Client
FROM        (
            SELECT      Firms, COUNT(*) AS NUM_OF_CAR
            FROM        FirmTable
            GROUP BY    Firms
            ) t
INNER JOIN  (
            SELECT      Client, Firms, COUNT(*) AS NUM_OF_CAR
            FROM        FirmTable a
            INNER JOIN  ClientTable b ON a.Car = b.Car
            GROUP BY    Client, Firms
            ) u
ON          t.Firms = u.Firms AND t.NUM_OF_CAR = u.NUM_OF_CAR
WHERE       t.Firms = 'GD1'

```
I'm also new at mysql but you can try this.

```
SELECT DISTINCT Client from ClientTable where CarRented=(SELECT Car from FirmTable where Firms='GD1');

```