32404

GROUP_CONCAT multiple fields with a different separator

Question:

Is it possible to do something like:

GROUP_CONCAT(user, price SEPARATOR ', ') AS items

The result is John3.99, Mike24.99

What I need is something like:

John - 3.99, Mike - 24.99

Basically use another type of separator for price field.

Answer1:

GROUP_CONCAT(CONCAT(user, ' - ', price) SEPARATOR ', ') AS items

Or just

GROUP_CONCAT(user, ' - ', price SEPARATOR ', ') AS items

Answer2:

Try this way

GROUP_CONCAT( DISTINCT CONCAT(user,',',Price SEPERATOR) ORDER BY items SEPARATOR ';' )

Recommend

  • Group results in subgroups
  • Return type in demangled member function name
  • Wikipedia API and SPARQL in a single query
  • Query LDAP for all computer objects created in the last 24 hours
  • How to call a html page and make it as pop up window in JavaScript?
  • R Multiple Regression Loop and Extract Coefficients
  • Is there a built-in shortcut key for selecting the owner of the currently active form?
  • What I can use subquery instead for search MAX()?
  • execute .sql file using command line
  • how to call delegate method, iphone
  • Re-order an array's items based on several criteria
  • How to set a dynamic form fields to dirty or touched with angular?
  • How to use template selector within a ContentPresenter in Windows 8.1
  • how can i close the resultSet, prepareStatement, conn in several methods below to avoid rs close and
  • Working with django : Proxy setup
  • Getting CKEditor to work with Flask Admin
  • How to use SerialPort class more reliably
  • ASP.NET: replacing UpdatePanel with Jquery?
  • How do methods within a class access class constant variables?
  • Making query to find nearest multiple(Lat,Long) from the single(Lat,Long)
  • spring security manual login best practice
  • Wicket - getting body of markup element
  • Implementation of timeout in LDAP
  • First dynamically-added TinyMCE editor displays, others do not
  • how to add dashed border on highcharts “area” graph for every point
  • How to use Flask's render_template from an ajax POST form submit
  • Generate and export point cloud from Project Tango
  • When to use the tag in the head and body section of a html page? [duplicate]
  • How to use Kaminari pagination gem with Sinatra and Mongoid?
  • Runtime complexity of getting the length of a string in different representations
  • JavaScript Regex to Match Boundaries of Words with diacritics
  • How to get rgb from transparent pixel in js
  • Computing the discrete fourier transform of audio data with FFTW
  • Using Service Component Runtime
  • convert json to excel in java
  • Create/delete users from text file using Bash script