Skip to content

Instantly share code, notes, and snippets.

@artygrand
Created September 28, 2017 11:59
Show Gist options
  • Save artygrand/2a3cbcda5cadf76c8c623d037d04dba4 to your computer and use it in GitHub Desktop.
Save artygrand/2a3cbcda5cadf76c8c623d037d04dba4 to your computer and use it in GitHub Desktop.
SELECT entry.id as entry_id,
v_brand.value as brand,
v_year.value as year
FROM entity
JOIN entry
ON entity.id = entry.entity_id
JOIN value v_brand
ON v_brand.parameter_id = 1
AND v_brand.entry_id = entry.id
JOIN value v_year
ON v_year.parameter_id = 2
AND v_year.entry_id = entry.id
WHERE entity.name = 'Car'
ORDER BY year DESC, brand ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment