Click here to Skip to main content
15,746,534 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I have 3 tables, Users, Employees and Teachers.
Employees joins users ON user_id and Teachers joins users ON user_id as well.
Employees and Teachers have some matching field names as well.

I need combined results and all 3 tables.
For example I need name from these tables

I tried the below query.

I want to know how to use this query in codeigniter query builder to get the results.

What I have tried:

(SELECT IF( IS NULL or = '',, as name  FROM users u
LEFT JOIN teachers t ON = t.user_id
LEFT JOIN employees e on = e.user_id) x
Updated 28-Mar-21 6:10am
nyt1972 28-Mar-21 12:10pm    
I resolved my problem by combining results array.

$results = array_merge($result1,$result2);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900