If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Record concat display

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-23-07, 01:25
jonasalbert20 jonasalbert20 is offline
Registered User
 
Join Date: Jun 2006
Posts: 2
Record concat display

We usually do this in SQL Server...

Code:
declare @a varchar(100)

select @a = isnull(@a, '') + convert(varchar(10), a) + '-'
from (  select 1 as a union all
	select 2 as a union all
	select 3 as a union all
	select 4 as a union all
	select 5 as a 
	) as tbl
select @a = left(@a, len(@a) - 1)
select @a as a
i want is to display this in a single column with a delimeter. On the below example, it is delimeted with a minus sign.


How can we do this?


Result set should be like this...

select '1-2-3-4-5' as a
Reply With Quote
  #2 (permalink)  
Old 01-23-07, 08:15
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Code:
select group_concat(a separator '-')
from (  select 1 as a union all
	select 2 as a union all
	select 3 as a union all
	select 4 as a union all
	select 5 as a 
	) as t
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On