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'
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.