I need to retrieve all of a specified user’s listings that are in a specific category.
SELECT title,listing_id, description, category FROM listing WHERE category = $category AND poster = $user;
Unfortunately, there’s no way to retrieve all of the listings in
a category independently of the poster, as you ultimately need a
WHERE clause that acts on either
You can easily modify this recipe to search for all of the listings in a category from all of the user’s friends:
SELECT title, url, description, price category FROM listing WHERE category = $category AND poster IN (SELECT uid2 FROM friend WHERE uid1 = $user);