How to get the value of one column based on the value of other column of same row in case of one to many relation in MySql

Clash Royale CLAN TAG#URR8PPP
How to get the value of one column based on the value of other column of same row in case of one to many relation in MySql
There are two tables say t1 and t2 with one to many relations (t1 having multiple records in t2), below image is t2.
t1
t2
t1
t2
t2

Please help me write MySQL query to fetch all the records of t1 with join to get value where title is 'First Name' in t2
t1
value
title
t2
Note: my_fr_id is foreign key (refers to primary key of t1)
my_fr_id
t1
Hope I'm clear with my query, thank you.
1 Answer
1
Without knowing the structure of t1 it's difficult to be exact but this is probably close (it assumes my_fr_id is a foreign key to t1.id):
t1
my_fr_id
t1.id
SELECT t1.*, t2.value
FROM t1
JOIN t2 ON t2.my_fr_id = t1.id AND t2.title = 'First Name'
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.