开发者

Find all characters in a table column of MySQL database?

开发者 https://www.devze.com 2023-03-07 08:57 出处:网络
Is there any easy way to find out all characters used in a specific column of a table in MySQL? For example, these records:

Is there any easy way to find out all characters used in a specific column of a table in MySQL?

For example, these records:

"title"
"DP&E"
"UI/O"
"B,B@M"

All the ch开发者_如何转开发aracters used in the "title" column would be: DPEUIOBM&/@,


I'm not aware of any means to do this easily using MySQL. The best you'll be able to do is to test each potential character one by one with exists statements. This will be very slow, too, since it'll lead to reading your whole table as many times as there are characters that are not present.

If you've the possibility, create a temporary table that aggregates your needed data into a huge text field, dump it, and populate a compatible table in PostgreSQL. This will allow you to extract the needed data using a query that looks like this:

select distinct regexp_split_to_table(yourfield, '') as letter
from yourtable;

It'll still be very slow, but at least you'll go through the data a single time.

0

精彩评论

暂无评论...
验证码 换一张
取 消