0

I am trying to create a view and would like to display the firstName and lastName columns from a table as one column (User) in a view.

The view is using a left join. What I would like to do is join on userID from tableA with concat of firstName and lastName from tableB.

Is this possible in MySql? I have seen some proposed solutions for SQL Server.

Instead of displaying emailAddress column as per below view, I want to display a concat of firstName and lastName columns.

create or replace view document.Documents
as
select
    d.documentID
    ,cu.emailAddress as createdByUser
from document.Document as d
        left join customer.User as cu
            on cu.userID = d.recCreatedByUserID

1 Answer 1

0

Yes, use concat or concat_ws:

CREATE VIEW myview AS  
  SELECT concat_ws(' ', firstName, lastName) as "User" 
  FROM mytable; 
1
  • Thanks for the initial answer. I updated the question to reflect a more detailed scenario of what I am trying to achieve.
    – kravb
    Commented May 25, 2019 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.