Home > Software engineering >  How can I switch order names in postgresql?
How can I switch order names in postgresql?

Time:01-25

I have my column full_name in the table Student, but the order of name is last name and first name

Smith, John
Brown, Jenny

And I would like to switch it to

John Smith
Jenny Brown

Thank you for your help.

CodePudding user response:

Splitting names into separate columns is the right way to go. You can use "split_part" to create 2 new columns in your data model.

    select full_name, 
     split_part(full_name, ',', 2) as first_name, 
     split_part(full_name, ',', 1) as last_name
    from student
  •  Tags:  
  • Related