Hello I’m getting results in format
location1 2 4
location2 3 2
location3 0 0
location1 1 0
How can I trim results so that row returning 0 and 0 is not displayed ? thank you
……………..
Here is Mysql query, I don’t know how to trim it from MySQL so I thought using PHP ..
SELECT hotelas.name, hotelas.address, hotelas.city, hotelas.country, hotelas.hotel_id
AS hotelid,
COUNT( DISTINCT apart.apartman_id ) AS number_of_free_ap,
COUNT( DISTINCT room.apartman_id ) AS num_of_free_rooms
FROM hotel AS hotelas
LEFT JOIN apartman AS apart ON ( apart.apartman_hotel = hotelas.hotel_id
AND apart.occupied =0
AND apart.what =1 )
LEFT JOIN apartman AS room ON ( room.apartman_hotel = hotelas.hotel_id
AND room.occupied =0
AND room.what =0 )
GROUP BY hotelas.hotel_id
TABLE field what, 0 – for room, 1 – apartment
So I get a few columns among which the most important ones are count columns , free rooms and free apartments. So I have a test hotel which is full 0 rooms and 0 apartments and I want is removed from this list where all other hotels have at least one room or one apartment available.
if you are querying you database to get this information and you can change the query, that would be the best place for it.
If you are getting this in PHP from some other source (CSV or something), or you don’t have control over the query, use
array_filter():