My latest project has turned out to be quite challenging. A lot of select queries within select queries between tables that are not related or share any similar information. Also trying to control the results when records get grouped together has been very interesting.
GROUP_CONCAT is a great way of grouping records and not lose variables that you’ll need later. For example; I have a table where magazines share the same title but some can be gifted and some can’t. By using GROUP_CONCAT I can keep track of how many magazines can be gifted.
select *, GROUP_CONCAT(Gift) as gGift from Campaigns group by MagazineThe result I get from gGift will be the combined values from all the magazines that have the same Magazine name.
