2

I'm looking to create a view that concatenates two columns from two tables together. the scenario is as follows:

Table1 - Parent

Id
fname
lname
age

Table2 – child

Id
parent_id
fname
age

view – child

Id
firstlast
age

Given that the child table has a fk reference to parent’s ID, and parent has a lname column that I’m interested in, how would one create a view that contains

child(id),

child(fname) . . parent(lname) as fullname

child(age)

the fullname would appear 'Jimmy Smith'

1
  • 1
    SELECT CONCAT(table1.column, ', ', table2.column) FROM table1 JOIN table2 ON [condition goes here]
    – A.O.
    Mar 4, 2014 at 21:03

1 Answer 1

6

Try the following :-

select c.id, concat(c.fname, p.lname) as full_name from
parent p
inner join
child c
on p.id = c.parent_id
1
  • Thanks, fast reply, worked great. just gotta add the space in there :)
    – downbySF
    Mar 4, 2014 at 21:22

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.