Created
June 14, 2009 20:26
-
-
Save tpitale/129804 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- query for user.items, which is User => sales => sale_items => item | |
SELECT "items"."id", "items"."item_code", "items"."item_number", "items"."description", "items"."size", "items"."retail", "items"."vintage" | |
FROM "items" | |
INNER JOIN "sale_items" | |
ON "items"."id" = "sale_items"."item_id" | |
INNER JOIN "sales" | |
ON "sale_items"."sale_id" = "sales"."id" | |
INNER JOIN "users" | |
ON "sales"."user_id" = "users"."id" | |
WHERE "sale_items"."id" = 1025 -- The id here is actually for a user, which is what I want: "users"."id" = 1025 | |
GROUP BY "items"."id", "items"."item_code", "items"."item_number", "items"."description", "items"."size", "items"."retail", "items"."vintage" | |
ORDER BY "items"."id" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment