how to select one table then join another table mysql

By Lion Smith

so i have two tables.


users_id   |   firstname    |  lastname
10001      |      mike      |    lapiz
10002      |      tom       |    jerry


profile_id   |   department   |   specialization
10001        |    Health Dept |     Heart
10002        |   Brain Dept   |     Brain

maybe youre curious why i separate the name of the user and the profile.. i have my on reasons for that.. what i wanted to do is to select my all fields fromprofilethen join theusers` table

what i want to be the result is

users_id | firstname   |  lastname | profile_id  | department   |specialization
10001    |  mike       |   lapiz   |  1001       |  health dept |   heart

this is my query..

$sql = SELECT a.profile_id,a.department,a.specialization FROMtbl_profileAS a LEFT JOIN (SELECT users_id,firstname,lastname FROMtbl_users) AS b ON a.profile_id = b.users_id

what happen is it only display the profile table.. it is not displaying the other table.. and when i tried to LEFT JOIN (SELECT b.users_id,b.firstname,b.lastname FROMtbl_users) AS b

it give me an error unknown column b.users_id

Source: Stack Overflow


Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273