What I am wanting to do is if there is an entry in “player_shops” for the account ID then have a specific where clause, otherwise have no where clause. If that makes sense. Here is my code:
SELECT *,
SUM(acc.gold_coins + shop.gold_coins) AS total_gold
FROM accounts AS acc
, player_shops AS shop
WHERE acc.acc_id = shop.acc_id
GROUP BY acc.acc_id
ORDER BY total_gold DESC
LIMIT 100
I want that WHERE clause to only be there IF the is a player_shop entry for the specified account ID.
Any help?
You better use JOIN.
I’m not sure about IF syntax. It depends on what db you use.