php - Select all from MySql and join other
I have this codeigniter function
function allClients($orderby = 'clients_company_name', $sort = 'ASC')
{
//profiling::
$this->debug_methods_trail[] = __function__;
//declare
$conditional_sql = '';
//check if any specifi ordering was passed
if (! $this->db->field_exists($orderby, 'clients')) {
$orderby = 'clients_company_name';
}
//check if sorting type was passed
$sort = ($sort == 'asc' || $sort == 'desc') ? $sort : 'ASC';
//
It selects all data from table clients. One of them is "client_team_profile_id" - the owner of this client.
I also need to join other table - team profiles. There we can find team_profile_id (there are ids of users in system) and team_profile_full_name - names of users.
{-code-2}
I need to select all data from table CLIENTS (as we can see - Select *) and also get name of team user connected to client and set a parameter for result - AS f.ex. client_owner_name.
I appreciate your help.
Answer
Answer
Answer
Answer
Answer
Solution:
So you can add this JOIN to your existing query
You may also need to change this bit of code to use the table alias like so
And also