Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

406
Views
Split data from a column and insert to another table in postgresql

I'm trying to split data from Username column in a table like this:

Table1
ID  Username
1   UserA,UserB,UserC

and I want to insert it to another table. the result will be like this:

Table2
ID  Username
1   UserA
1   UserB
1   UserC

is this possible to do this in postgresql?

thanks in advance

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can split the value and then unnest it:

insert into table2 (id, username)
select t1.id, ut.username
from table1 t1
  cross join unnest(string_to_array(t1.username), ',')) as ut(username)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!