I have 4 MySQL Tables shown here:SQL Fiddle
I need to select station name, brand, fuel_type and fual_price for each station in given set and fuel typ in given set, e.q all Shell stations with fuel Diesel and Natural.
I would like to have all data related to one station in one row, which means I have e.g. 5 fuel types/prices for 1 station.
Example output –
id | name | brand | fuel-data
---------------------------------------------------------
1 | Brzotice | Shell | Natural95-37.9, Diesel Power-45.8
Could you please help me?
I think this will give you want you want:
See SQL Fiddle with Demo
Basically this query joins all of your tables. Then to get the
fuel_datafield it applies both theCONCAT()and theGROUP_CONCAT()functions