Skip to content

Instantly share code, notes, and snippets.

@iammart
Created October 30, 2012 18:11
Show Gist options
  • Select an option

  • Save iammart/3981967 to your computer and use it in GitHub Desktop.

Select an option

Save iammart/3981967 to your computer and use it in GitHub Desktop.
$query = @mysql_query("
SELECT pm.id, pv.id AS variation_id, pm.title, pm.vat_exempt, pm.thumbimage, MIN(pv.price) AS from_price, pv.price
FROM (
SELECT id, title, thumbimage, vat_exempt FROM products_main
WHERE is_log_token != 'Y'
AND is_report_token != 'Y'
AND enabled = 'Y'
AND viewable = 'Y'
ORDER BY `id` DESC LIMIT 1
) AS pm
INNER JOIN product_variations AS pv ON (pm.id = pv.product_id)
WHERE pv.product_id = pm.id AND pv.is_hire_product = 'N'
");
@a1phanumeric

Copy link
Copy Markdown

You did it with the sub select?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment