Skip to content

Instantly share code, notes, and snippets.

@Dobby89
Created December 9, 2016 16:05
Show Gist options
  • Save Dobby89/841ee1889c406d47f096180d7f666658 to your computer and use it in GitHub Desktop.
Save Dobby89/841ee1889c406d47f096180d7f666658 to your computer and use it in GitHub Desktop.
SQL Query with Concat and Group Concat
SELECT
p.product_id,
pd.name,
pd.description,
pd.title_tag AS meta_title,
pd.meta_keywords,
pd.meta_description,
CONCAT('http://www.domain.co.uk/', u.keyword) AS URL,
GROUP_CONCAT(pt.tag) AS tags,
p.status
FROM
product AS p
Left Join product_description AS pd ON pd.product_id = p.product_id
Left Join url_alias AS u ON u.query = CONCAT('product_id=',p.product_id)
Left Join product_tags AS pt ON pt.product_id = p.product_id
GROUP BY p.product_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment