I have two my sql tables. Table A
reference author order_ first_name_initial last_name
4222 13454091 13454091 null null
4222 13454092 13454092 null null
4222 13454093 13454093 null null
4223 13454094 13454094 null null
4223 13454095 13454095 null null
Table B is
0 first_name_initial last_name
4222 H. Abbaszadeh
4222 S. A. Ebrahimi
4222 M. M. Akhavan
4223 E. L. Abel
4223 H. Ackermann
4224 H. Seidler
4224 Y. S. Kagan
I need to bring values of first_name_initial and last_name from table B to table A, in the same order as they are in table B. It is safe to assume that the 4222 would occur 3 times in both table and so the 4223, and so on. How can I do that.
A simple join will give you what you need, and an order by
select distinct a.*, b.first_name_initial, b.last_name
from tablea a
left join tableb b on a.reference = b.reference
order by a.reference, a.order
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.