SELECT cart location id AS location id location name AS location name

1
SELECT "cart".*, "location"."id" AS "location.id", "location"."name" AS "location.name", "location"."description" AS "location.description", "location"."address" AS "location.address", "location"."apt_floor" AS "location.apt_floor", "location"."active" AS "location.active", "location"."stripe_account_id" AS "location.stripe_account_id", "location"."created_at" AS "location.created_at", "location"."updated_at" AS "location.updated_at", "transactions"."id" AS "transactions.id", "transactions"."cart_id" AS "transactions.cart_id", "transactions"."user_id" AS "transactions.user_id", "transactions"."credit_card_id" AS "transactions.credit_card_id", "transactions"."parent_transaction_id" AS "transactions.parent_transaction_id", "transactions"."type" AS "transactions.type", "transactions"."status" AS "transactions.status", "transactions"."scheduled_at" AS "transactions.scheduled_at", "transactions"."initial" AS "transactions.initial", "transactions"."external_id" AS "transactions.external_id", "transactions"."amount" AS "transactions.amount", "transactions"."processor_fee" AS "transactions.processor_fee", "transactions"."net_amount" AS "transactions.net_amount", "transactions"."extra_fields" AS "transactions.extra_fields", "transactions"."balance_transaction" AS "transactions.balance_transaction", "transactions"."transferred" AS "transactions.transferred", "transactions"."available_on" AS "transactions.available_on", "transactions"."created_at" AS "transactions.created_at", "transactions"."updated_at" AS "transactions.updated_at", "promo_codes"."id" AS "promo_codes.id", "promo_codes"."bundle_main_id" AS "promo_codes.bundle_main_id", "promo_codes"."discount_product_id" AS "promo_codes.discount_product_id", "promo_codes"."created_by" AS "promo_codes.created_by", "promo_codes"."active" AS "promo_codes.active", "promo_codes"."multiple_products_mode" AS "promo_codes.multiple_products_mode", "promo_codes"."stackable" AS "promo_codes.stackable", "promo_codes"."mode" AS "promo_codes.mode", "promo_codes"."problem_cart_id" AS "promo_codes.problem_cart_id", "promo_codes"."issue_reason" AS "promo_codes.issue_reason", "promo_codes"."name" AS "promo_codes.name", "promo_codes"."type" AS "promo_codes.type", "promo_codes"."max_number_of_usages" AS "promo_codes.max_number_of_usages", "promo_codes"."start_date" AS "promo_codes.start_date", "promo_codes"."expire_date" AS "promo_codes.expire_date", "promo_codes"."min_order_sum" AS "promo_codes.min_order_sum", "promo_codes"."value" AS "promo_codes.value", "promo_codes"."max_discount_products" AS "promo_codes.max_discount_products", "promo_codes"."max_usages_per_user" AS "promo_codes.max_usages_per_user", "promo_codes"."discount_type" AS "promo_codes.discount_type", "promo_codes"."created_at" AS "promo_codes.created_at", "promo_codes"."updated_at" AS "promo_codes.updated_at", "promo_codes->cart_promo_code"."created_at" AS "promo_codes.cart_promo_code.created_at", "promo_codes->cart_promo_code"."updated_at" AS "promo_codes.cart_promo_code.updated_at", "promo_codes->cart_promo_code"."cart_id" AS "promo_codes.cart_promo_code.cart_id", "promo_codes->cart_promo_code"."promo_code_id" AS "promo_codes.cart_promo_code.promo_code_id", "promo_codes->products"."id" AS "promo_codes.products.id", "promo_codes->products"."badge_id" AS "promo_codes.products.badge_id", "promo_codes->products"."receipt_section_id" AS "promo_codes.products.receipt_section_id", "promo_codes->products"."name" AS "promo_codes.products.name", "promo_codes->products"."short_description" AS "promo_codes.products.short_description", "promo_codes->products"."description" AS "promo_codes.products.description", "promo_codes->products"."image" AS "promo_codes.products.image", "promo_codes->products"."type" AS "promo_codes.products.type", "promo_codes->products"."price" AS "promo_codes.products.price", "promo_codes->products"."include_taxes" AS "promo_codes.products.include_taxes", "promo_codes->products"."archived_at" AS "promo_codes.products.archived_at", "promo_codes->products"."auto_utensils" AS "promo_codes.products.auto_utensils", "promo_codes->products"."defaultSpiciness" AS "promo_codes.products.defaultSpiciness", "promo_codes->products"."labels" AS "promo_codes.products.labels", "promo_codes->products"."display_sort" AS "promo_codes.products.display_sort", "promo_codes->products"."kitchen_sort" AS "promo_codes.products.kitchen_sort", "promo_codes->products"."receipt_sort" AS "promo_codes.products.receipt_sort", "promo_codes->products"."created_at" AS "promo_codes.products.created_at", "promo_codes->products"."updated_at" AS "promo_codes.products.updated_at", "promo_codes->products->promo_code_product"."created_at" AS "promo_codes.products.promo_code_product.created_at", "promo_codes->products->promo_code_product"."updated_at" AS "promo_codes.products.promo_code_product.updated_at", "promo_codes->products->promo_code_product"."promo_code_id" AS "promo_codes.products.promo_code_product.promo_code_id", "promo_codes->products->promo_code_product"."product_id" AS "promo_codes.products.promo_code_product.product_id", "promo_codes->locations"."id" AS "promo_codes.locations.id", "promo_codes->locations"."name" AS "promo_codes.locations.name", "promo_codes->locations"."description" AS "promo_codes.locations.description", "promo_codes->locations"."address" AS "promo_codes.locations.address", "promo_codes->locations"."apt_floor" AS "promo_codes.locations.apt_floor", "promo_codes->locations"."active" AS "promo_codes.locations.active", "promo_codes->locations"."stripe_account_id" AS "promo_codes.locations.stripe_account_id", "promo_codes->locations"."created_at" AS "promo_codes.locations.created_at", "promo_codes->locations"."updated_at" AS "promo_codes.locations.updated_at", "promo_codes->locations->promo_code_location"."created_at" AS "promo_codes.locations.promo_code_location.created_at", "promo_codes->locations->promo_code_location"."updated_at" AS "promo_codes.locations.promo_code_location.updated_at", "promo_codes->locations->promo_code_location"."promo_code_id" AS "promo_codes.locations.promo_code_location.promo_code_id", "promo_codes->locations->promo_code_location"."location_id" AS "promo_codes.locations.promo_code_location.location_id", "products"."id" AS "products.id", "products"."cart_id" AS "products.cart_id", "products"."product_id" AS "products.product_id", "products"."count" AS "products.count", "products"."spiciness" AS "products.spiciness", "products"."fixed_price" AS "products.fixed_price", "products"."created_at" AS "products.created_at", "products"."updated_at" AS "products.updated_at", "products->product"."id" AS "products.product.id", "products->product"."badge_id" AS "products.product.badge_id", "products->product"."receipt_section_id" AS "products.product.receipt_section_id", "products->product"."name" AS "products.product.name", "products->product"."short_description" AS "products.product.short_description", "products->product"."description" AS "products.product.description", "products->product"."image" AS "products.product.image", "products->product"."type" AS "products.product.type", "products->product"."price" AS "products.product.price", "products->product"."include_taxes" AS "products.product.include_taxes", "products->product"."archived_at" AS "products.product.archived_at", "products->product"."auto_utensils" AS "products.product.auto_utensils", "products->product"."defaultSpiciness" AS "products.product.defaultSpiciness", "products->product"."labels" AS "products.product.labels", "products->product"."display_sort" AS "products.product.display_sort", "products->product"."kitchen_sort" AS "products.product.kitchen_sort", "products->product"."receipt_sort" AS "products.product.receipt_sort", "products->product"."created_at" AS "products.product.created_at", "products->product"."updated_at" AS "products.product.updated_at", "products->product->modifiers"."product_id" AS "products.product.modifiers.product_id", "products->product->modifiers"."modifier_id" AS "products.product.modifiers.modifier_id", "products->product->modifiers"."enabled" AS "products.product.modifiers.enabled", "products->product->modifiers"."default_" AS "products.product.modifiers.default_", "products->product->modifiers"."visible" AS "products.product.modifiers.visible", "products->product->modifiers"."created_at" AS "products.product.modifiers.created_at", "products->product->modifiers"."updated_at" AS "products.product.modifiers.updated_at", "products->product->modifiers->modifier"."id" AS "products.product.modifiers.modifier.id", "products->product->modifiers->modifier"."station_id" AS "products.product.modifiers.modifier.station_id", "products->product->modifiers->modifier"."modifier_type_id" AS "products.product.modifiers.modifier.modifier_type_id", "products->product->modifiers->modifier"."receipt_section_id" AS "products.product.modifiers.modifier.receipt_section_id", "products->product->modifiers->modifier"."name" AS "products.product.modifiers.modifier.name", "products->product->modifiers->modifier"."price" AS "products.product.modifiers.modifier.price", "products->product->modifiers->modifier"."image" AS "products.product.modifiers.modifier.image", "products->product->modifiers->modifier"."sort" AS "products.product.modifiers.modifier.sort", "products->product->modifiers->modifier"."created_at" AS "products.product.modifiers.modifier.created_at", "products->product->modifiers->modifier"."updated_at" AS "products.product.modifiers.modifier.updated_at", "products->product->modifiers->modifier->modifier_type"."id" AS "products.product.modifiers.modifier.modifier_type.id", "products->product->modifiers->modifier->modifier_type"."name" AS "products.product.modifiers.modifier.modifier_type.name", "products->product->modifiers->modifier->modifier_type"."description" AS "products.product.modifiers.modifier.modifier_type.description", "products->product->modifiers->modifier->modifier_type"."behavior" AS "products.product.modifiers.modifier.modifier_type.behavior", "products->product->modifiers->modifier->modifier_type"."sort" AS "products.product.modifiers.modifier.modifier_type.sort", "products->product->modifiers->modifier->modifier_type"."created_at" AS "products.product.modifiers.modifier.modifier_type.created_at", "products->product->modifiers->modifier->modifier_type"."updated_at" AS "products.product.modifiers.modifier.modifier_type.updated_at", "products->product->locations"."id" AS "products.product.locations.id", "products->product->locations"."name" AS "products.product.locations.name", "products->product->locations"."description" AS "products.product.locations.description", "products->product->locations"."address" AS "products.product.locations.address", "products->product->locations"."apt_floor" AS "products.product.locations.apt_floor", "products->product->locations"."active" AS "products.product.locations.active", "products->product->locations"."stripe_account_id" AS "products.product.locations.stripe_account_id", "products->product->locations"."created_at" AS "products.product.locations.created_at", "products->product->locations"."updated_at" AS "products.product.locations.updated_at", "products->product->locations->product_location"."created_at" AS "products.product.locations.product_location.created_at", "products->product->locations->product_location"."updated_at" AS "products.product.locations.product_location.updated_at", "products->product->locations->product_location"."product_id" AS "products.product.locations.product_location.product_id", "products->product->locations->product_location"."location_id" AS "products.product.locations.product_location.location_id", "products->modifiers"."id" AS "products.modifiers.id", "products->modifiers"."cart_product_id" AS "products.modifiers.cart_product_id", "products->modifiers"."modifier_id" AS "products.modifiers.modifier_id", "products->modifiers"."value" AS "products.modifiers.value", "products->modifiers"."created_at" AS "products.modifiers.created_at", "products->modifiers"."updated_at" AS "products.modifiers.updated_at", "products->modifiers->modifier"."id" AS "products.modifiers.modifier.id", "products->modifiers->modifier"."station_id" AS "products.modifiers.modifier.station_id", "products->modifiers->modifier"."modifier_type_id" AS "products.modifiers.modifier.modifier_type_id", "products->modifiers->modifier"."receipt_section_id" AS "products.modifiers.modifier.receipt_section_id", "products->modifiers->modifier"."name" AS "products.modifiers.modifier.name", "products->modifiers->modifier"."price" AS "products.modifiers.modifier.price", "products->modifiers->modifier"."image" AS "products.modifiers.modifier.image", "products->modifiers->modifier"."sort" AS "products.modifiers.modifier.sort", "products->modifiers->modifier"."created_at" AS "products.modifiers.modifier.created_at", "products->modifiers->modifier"."updated_at" AS "products.modifiers.modifier.updated_at", "products->modifiers->modifier->modifier_type"."id" AS "products.modifiers.modifier.modifier_type.id", "products->modifiers->modifier->modifier_type"."name" AS "products.modifiers.modifier.modifier_type.name", "products->modifiers->modifier->modifier_type"."description" AS "products.modifiers.modifier.modifier_type.description", "products->modifiers->modifier->modifier_type"."behavior" AS "products.modifiers.modifier.modifier_type.behavior", "products->modifiers->modifier->modifier_type"."sort" AS "products.modifiers.modifier.modifier_type.sort", "products->modifiers->modifier->modifier_type"."created_at" AS "products.modifiers.modifier.modifier_type.created_at", "products->modifiers->modifier->modifier_type"."updated_at" AS "products.modifiers.modifier.modifier_type.updated_at" FROM (SELECT "cart"."id", "cart"."user_id", "cart"."location_id", "cart"."address_id", "cart"."orders_group_id", "cart"."uuid", "cart"."delivery_time", "cart"."delivery_time_utc", "cart"."order_time", "cart"."chopsticks", "cart"."utensils", "cart"."delivery_instructions", "cart"."packer_instructions", "cart"."status", "cart"."carryout", "cart"."asap", "cart"."asap_time", "cart"."delivery_rating", "cart"."temp_group_id", "cart"."external_ids", "cart"."bringg_id", "cart"."bringg_uuid", "cart"."initial_paid", "cart"."paid_at", "cart"."completed_at", "cart"."test_", "cart"."linked", "cart"."refunded", "cart"."taxes", "cart"."edit_deadline", "cart"."internal_transfer_id", "cart"."transfer_scheduled_at", "cart"."transferred", "cart"."edited", "cart"."created_at", "cart"."updated_at", "user"."id" AS "user.id", "user"."first_name" AS "user.first_name", "user"."last_name" AS "user.last_name", "user"."email" AS "user.email", "user"."phone_number" AS "user.phone_number", "user"."password" AS "user.password", "user"."facebook_id" AS "user.facebook_id", "user"."google_id" AS "user.google_id", "user"."active" AS "user.active", "user"."registered" AS "user.registered", "user"."one_signal_ids" AS "user.one_signal_ids", "user"."stripe_profile_id" AS "user.stripe_profile_id", "user"."bringg_id" AS "user.bringg_id", "user"."access_token" AS "user.access_token", "user"."type" AS "user.type", "user"."image" AS "user.image", "user"."editable" AS "user.editable", "user"."role_id" AS "user.role_id", "user"."test_" AS "user.test_", "user"."notification_settings" AS "user.notification_settings", "user"."created_at" AS "user.created_at", "user"."updated_at" AS "user.updated_at" FROM "cart" AS "cart" INNER JOIN "user" AS "user" ON "cart"."user_id" = "user"."id" WHERE "cart"."location_id" IS NOT NULL AND "user"."registered" = true AND ( SELECT "cart_id" FROM "cart_product" AS "products" WHERE ("products"."cart_id" = "cart"."id") LIMIT 1 ) IS NOT NULL ORDER BY "cart"."id" DESC LIMIT 10 OFFSET 0) AS "cart" LEFT OUTER JOIN "location" AS "location" ON "cart"."location_id" = "location"."id" LEFT OUTER JOIN "transaction" AS "transactions" ON "cart"."id" = "transactions"."cart_id" LEFT OUTER JOIN ( "cart_promo_code" AS "promo_codes->cart_promo_code" INNER JOIN "promo_code" AS "promo_codes" ON "promo_codes"."id" = "promo_codes->cart_promo_code"."promo_code_id") ON "cart"."id" = "promo_codes->cart_promo_code"."cart_id" LEFT OUTER JOIN ( "promo_code_product" AS "promo_codes->products->promo_code_product" INNER JOIN "product" AS "promo_codes->products" ON "promo_codes->products"."id" = "promo_codes->products->promo_code_product"."product_id") ON "promo_codes"."id" = "promo_codes->products->promo_code_product"."promo_code_id" LEFT OUTER JOIN ( "promo_code_location" AS "promo_codes->locations->promo_code_location" INNER JOIN "location" AS "promo_codes->locations" ON "promo_codes->locations"."id" = "promo_codes->locations->promo_code_location"."location_id") ON "promo_codes"."id" = "promo_codes->locations->promo_code_location"."promo_code_id" INNER JOIN "cart_product" AS "products" ON "cart"."id" = "products"."cart_id" LEFT OUTER JOIN "product" AS "products->product" ON "products"."product_id" = "products->product"."id" LEFT OUTER JOIN "product_modifier" AS "products->product->modifiers" ON "products->product"."id" = "products->product->modifiers"."product_id" LEFT OUTER JOIN "modifier" AS "products->product->modifiers->modifier" ON "products->product->modifiers"."modifier_id" = "products->product->modifiers->modifier"."id" LEFT OUTER JOIN "modifier_type" AS "products->product->modifiers->modifier->modifier_type" ON "products->product->modifiers->modifier"."modifier_type_id" = "products->product->modifiers->modifier->modifier_type"."id" LEFT OUTER JOIN ( "product_location" AS "products->product->locations->product_location" INNER JOIN "location" AS "products->product->locations" ON "products->product->locations"."id" = "products->product->locations->product_location"."location_id") ON "products->product"."id" = "products->product->locations->product_location"."product_id" LEFT OUTER JOIN "cart_product_modifier" AS "products->modifiers" ON "products"."id" = "products->modifiers"."cart_product_id" LEFT OUTER JOIN "modifier" AS "products->modifiers->modifier" ON "products->modifiers"."modifier_id" = "products->modifiers->modifier"."id" LEFT OUTER JOIN "modifier_type" AS "products->modifiers->modifier->modifier_type" ON "products->modifiers->modifier"."modifier_type_id" = "products->modifiers->modifier->modifier_type"."id" ORDER BY "cart"."id" DESC;