Hi Experts,
I have two tables that rows are linked by the 'PersonRef' field.
Table 'person' example:
PersonRef FirstName LastName
12 Jim Smith
23 Alex Lewis
34 Linda Smith
Table 'person_meta' example:
PersonRef Field Value
12 Age 24
12 Title Mr
23 Age 24
23 Title Mr
34 Age 24
34 Title Mrs
I am looking for a sql query (mysqli_connect) that would return any person who is 'Age' = '24' and 'LastName' = 'Smith' but in an array with this format:
[0] => array('FirstName'=>'Jim','LastName'=>'Smith','Meta'=>array('Title'=>'Mr','Age'=>'24'))
[1] => array('FirstName'=>'Linda','LastName'=>'Smith','Meta'=>array('Title'=>'Mrs','Age'=>'24'))
So basically searching the two tables and linking the data. Removing PersonRef 23 as they don't have a LastName Smith.
Any help would be gratefully received. I've been going round in circles with Joins.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.