How to separate and count string from TEXT column PostgreSQL
NickName:gsanchez92 Ask DateTime:2016-11-15T21:32:07

How to separate and count string from TEXT column PostgreSQL

I have a field in the Client table called "Attachment Name" which has the names of every attachment that a client has, the way the names are saved are the following, it alwas starts with a “^” character, then the name of the file, when you have to save another file the same character is placed. So for example, in client number 1423 we have "^file1^userGuide^file3", in this case we have 3 files, File1, userGuide and File3. What i need is a way to know the clients that have only ONE file attached, or the ones that have more than one file.

I know this is an awfull way to store file names, but i did not do it this way and its not my call to change it.

I have been working with this sentence:

Select regexp_split_to_array("attachment_name", E'\\^+') from clients

But i could not make it work at all.

Copyright Notice:Content Author:「gsanchez92」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/40611137/how-to-separate-and-count-string-from-text-column-postgresql

More about “How to separate and count string from TEXT column PostgreSQL” related questions

How to fetch TEXT column value from postgresql

I have a the following simple table in postgreSQL: CREATE TABLE data ( id bigint NOT NULL, text_column text, ); The values of the text_column , as I see them in the phpPgAdmin web site, are numbe...

Show Detail

Copy and convert text in postgresql column

Let's say I have some JSON stored in postgresql like so: {"the": [0, 4], "time": [1, 5], "is": [2, 6], "here": [3], "now": [7]} This is an inverted

Show Detail

Query to separate, then count a field of comma separated values in postgresql

I have a table in postgresql that starts like this: car_id part_ids total_inventory ------ -------- ---------- 10134 101,506,589 50 12236 201,506,101 20 78865 201,399,304 10 I'm

Show Detail

Get the name of a Column (PostgreSQL)

How can I get the name of the first column out of a table in PostgreSQL? I know how to get them all but how do I separate the first one from the others ? public void getColumns(String username,

Show Detail

I need to separate the text from a string based on column names

I am working on OCR based Android app, getting this text as string from the attached image dynamically (getting the text in Horizontal Direction from the image) Text from Image: "Part Name Part C...

Show Detail

Postgresql: count entries by another column

In Postgresql,  if you have a table that has two columns: a list of purchases, and another column that is the state in which those purchases were made, how would you count the number of purchases by

Show Detail

How to count how many entries in a column are numeric using PostgreSQL

I am trying to count how many entries are in a column that are both numeric and fulfill other conditions. I understand how that script is meant to look in SQL: SELECT COUNT(ingredients) FROM

Show Detail

Hibernate with long text column with Oracle and PostgreSQL

I'm trying make an entity work with Oracle (11.2) and PostgreSQL(9.4) in a Spring Boot (1.4.4) application. My entity contains a long text field (over 4000 characters). The appropriate data type in

Show Detail

n-grams from text in PostgreSQL

I am looking to create n-grams from text column in PostgreSQL. I currently split(on white-space) data(sentences) in a text column to an array. enter code hereselect regexp_split_to_array(sentenceD...

Show Detail

Rollback migration that changes column type from string to text where db is postgresql in rails 3.2

I have understood the solution for changing the column type from string to text while using postgresql and rails 3.2 provided here. I have also implemented it. But when I rollback this migration, it

Show Detail