group-concat

How to get multiple columns in one variable in mysql query

I have the table Articles -------- id,name,type_id Type--------------id,name article_type ----------article_id , type_id I using this query select A.name from types A inner join article_type B on ( B.type_id = A.id and article_id = 10) Now this query is working but it gives me separate rows but i want all types in one variables so...

How to prevent GROUP_CONCAT from creating a result when no input data is present?

Given the following MySQL query: SELECT `show`.`id` , GROUP_CONCAT( `showClips`.`clipId` ORDER BY `position` ASC ) AS 'playlist' FROM `show` INNER JOIN `showClips` ON ( `show`.`id` = `showClips`.`showId` ) ; I want to retrieve a list of all "shows" from the database, including the ids of contained "clips". ...

Am I using GROUP_CONCAT properly?

I'm selecting properties and joining them to mapping tables where they get mapped to filters such as location, destination, and property type. My goal is to grab all the properties and then LEFT JOIN them to the tables, and then basically get data that shows all the locations, destinations a property is attached to and the property type...

ORDER BY whether a GROUP_CONCAT contains a certain value?

I have properties and I need to list the ones mapped as "Founding Members" first, and then alphabetically while the rest that aren't need to come afterwards and be listed alphabetically. properties table: ------------------------ id name 1 Gaga Hotel 2 Foo Bar Resort properties_features ------------------------ feature_id pro...

using group_concat with other selection criteria - mySQL

I have two tables, arrc_PurchActivity and arrc_Voucher. The purchase activity table contains multiple records per purchase, tied together by the credit card authorization. I need to return a single row per purchase, plus pull in a field from the voucher table. If I just grab a few fields from the purchase activity table, like this: SEL...

Adding selected attribute to group_concat output in Codeigniter/MYSQL

Hello, I am outputing a simple list of options from dynamic select menus using Codeigniter/MYSQL. CONTROLLER $data['get_custom_fields'] = $this->db->query(" SELECT a.custom_field_name, a.custom_field_id, GROUP_CONCAT('<option name=\"',c.custom_field_value_id, '\" value=\"', c.custom_field_value_id , '\">',c.custom...

How do I concatenate strings from a subquery into a single row in mysql?

I have three tables: table "package" ----------------------------------------------------- package_id int(10) primary key, auto-increment package_name varchar(255) price decimal(10,2) table "zones" ------------------------------------------------------ zone_id varchar(32) primary key (ex of data: A1,...

mysql multiple-subquery group_concat query

I'm trying to show the boroughs and postcodes a particular town in is. My database is fairly well structured, with a table such as town, postcode and borough. There are also tables for each of the relationships town_postcode & town_borough. Ideally I want the data returned as: "Abbey Wood", "SE2", "Bexley, Greenwich" "Barbican", "EC1,...