how many records do you have like this?
AW
Main Topics
Browse All TopicsI have a table which looks like this (comma delimited):
"ID","Name","Expertise"
The "Expertise" column contains data that is semi-colon delimited (e.g. Apples;Bananas;Coconuts)
I want an SQL query to split the contents of the Expertise column apart so that I can get a list of all "Expertises" in the table and sort them in Alpha order.
Is this possible, or do I need to normalize in some way to achieve this result?
Thanks!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Here's a PostgreSQL version that works for the most part:
SELECT split_part( Expertise, ';', 1 ) AS expertise FROM tablename
UNION
SELECT split_part( Expertise, ';', 2 ) FROM tablename
UNION
SELECT split_part( Expertise, ';', 3 ) FROM tablename
UNION
....
You would have to do this as many times as there are "fields" in the Expertise column. Messy, but it works.
and even if you could use the Replace function as suggested, that will NOT produce the resultset that you need. The 'split' fields will still be seen, by Access as a SINGLE value, and you cannot sort these fields.
so if, instead of
Apples;Bananas;Coconuts
which already just happens to be in alphabetical order, the field contained:
Coconuts;Apples;Bananas
you would NOT be able to sort these values into alphabetical order. The SINGLE field would simply contain
Coconuts
Apples
Bananas
and the individual values would NOT exist independently, and could NOT be sorted.
AW
The easiest way (assuming you only want to do this once or on relatively rare occasions) would seem to be:
1) Export the column to a text file.
2) Use a text editor to Search and Replace, changing all semicolons to line feeds
3) Import the text file
If you need to do this on a regular basis VBA would seem to be the best choice. If this is the case I can post code that would perform the operation--just let me know.
Business Accounts
Answer for Membership
by: Arthur_WoodPosted on 2004-05-28 at 17:50:36ID: 11185156
there is no way for a Query to split the field. YOu will need to do that in code, after you have retrieved the records, and then you will need to normalize you database, and add a new table to hold the 'Expertise' items for each ID as separate rows.
AW