how to get data from two different table from wordpress database

Question

I have two different table in wordpress one is custom table and another is wp_usermeta table.

one email is matched from both table so i want to get data from both table using email address is matched. My query is:

$sql = "SELECT * FROM wp_usermeta,tbl_information 
WHERE   wp_usermeta.meta_value = 
tbl_information.account_email AND 
((wp_usermeta.meta_key = 'mycv') OR (wp_usermeta.meta_key = 'drivinglicence') OR 
(wp_usermeta.meta_key = 'first_name') OR (wp_usermeta.meta_key = 'last_name') OR 
(wp_usermeta.meta_key = 'address') OR (wp_usermeta.meta_key = 'nickname'))"

$infos = $wpdb->get_results($sql);

foreach ($infos as $u) {
      $users[$a->user_id][$a->meta_key] = $a->meta_value;
}
foreach ($users as $u) {
   <?php echo $u['first_name'].' '.$u['last_name'];?>
}

This is works but when i try to print tbl_information table data like one of the field is: account_name

So i try to print like <?php echo $u['account_name'];?>

But it wont work.

0
, , Sabbir 3 years 2020-07-14T01:10:25-05:00 0 Answers 60 views 0

Leave an answer

Browse
Browse