Skip to content

Commit

Permalink
Use some left joins instead of inner joins
Browse files Browse the repository at this point in the history
  • Loading branch information
ML-Chen committed Apr 24, 2020
1 parent 7a21309 commit fabcb2a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions database/cs4400spring2020.sql
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,11 @@ varchar(100),
GROUP_CONCAT(DISTINCT(FoodTruck.foodTruckName) SEPARATOR ',') AS foodTruckNames,
GROUP_CONCAT(DISTINCT(MenuItem.foodName) SEPARATOR ',') AS foodNames
FROM Station
INNER JOIN
LEFT OUTER JOIN
FoodTruck ON Station.stationName = FoodTruck.stationName
INNER JOIN
LEFT OUTER JOIN
MenuItem ON FoodTruck.foodTruckName = MenuItem.foodTruckName
INNER JOIN
LEFT OUTER JOIN
BuildingTag ON Station.buildingName = BuildingTag.buildingName
WHERE
(i_buildingName is NULL OR i_buildingName = Station.buildingName) AND
Expand Down
2 changes: 1 addition & 1 deletion server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def new_api() -> Response:
# helper endpoint handling:
if helper:
if a['queryType'] == 'Station':
cursor.execute('select distinct(capacityInfo.stationName) as stationName FROM FoodTruck INNER JOIN (select (capacity - count(foodTruckName)) as remainingCapacity, Station.stationName from Station inner join FoodTruck on Station.stationName = FoodTruck.stationName group by Station.stationName) as capacityInfo ON FoodTruck.stationName = capacityInfo.stationName where remainingCapacity>0;')
cursor.execute('select distinct(capacityInfo.stationName) as stationName FROM FoodTruck LEFT JOIN (select (capacity - count(foodTruckName)) as remainingCapacity, Station.stationName from Station inner join FoodTruck on Station.stationName = FoodTruck.stationName group by Station.stationName) as capacityInfo ON FoodTruck.stationName = capacityInfo.stationName where remainingCapacity>0;')
elif a['queryType'] == 'Staff':
cursor.execute('select Staff.username as staffUsername, CONCAT(firstName," ", lastName) as staffName from Staff left join `user` on Staff.username = `user`.username where Staff.foodTruckName is NULL')
elif a['queryType'] == 'Food':
Expand Down

0 comments on commit fabcb2a

Please sign in to comment.