I have table named 'company' and 'user'. The user table contains the id of company. Like for example:
A. User table
user_id | name | company_id |status
1 | john | 1 | active
B. Company table
company_id | name | status
1 | ABC | active
How to get the name of the company by their id in single sql query. such;
$query = "SELECT name as Username, company_id as Company_Name From `user` where status='active'";
That will give the result of:
Username | Company_Name
john | ABC
Any help or ideas on how to do this... Thanks in advance.