strawberry wrote:
> On 18 May, 19:20, lark <ham...@sbcdeglobalspam.net> wrote:
>> strawberry wrote:
>>> In a moment or two I'm going to have a table that looks a bit like
>>> this:
>>> id hyphenated
>>> 1 [all-bar-one]
>>> 2 [black-and-white]
>>> 3 [black-and-blue]
>>> 4 [all-for-one]
>>> >From which I'd like to generate a result set like this:
>>> all
>>> and
>>> bar
>>> black
>>> blue
>>> for
>>> one
>>> white
>>> Is there a simple way of doing this without resorting to PHP?
>> are the brackets part of the data?
>>
>> --
>> lark -- ham...@sbcdeglobalspam.net
>> To reply to me directly, delete "despam".
>
>
> Yes - but disregarding the brackets is the easy part!
>
try this:
select distinct SUBSTRING_INDEX(hyphenated,'-', 1) as col1 from t1
union
select distinct substring_index(substring(hyphenated,
instr(substring_index(hyphenated, '-', 2), '-')+1),'-',1) as col1 from t1
union
select distinct SUBSTRING_INDEX(hyphenated,'-',-1) as col1 from t1
order by col1
hyphenated is the name of column in t1 table.
--
lark --
EMAIL REMOVED
To reply to me directly, delete "despam".