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

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:

SQL
SELECT x.name
FROM
(SELECT IF(t.name IS NULL or t.name = '', e.name, t.name) as name  FROM users u
LEFT JOIN teachers t ON U.id = t.user_id
LEFT JOIN employees e on U.id = e.user_id) x
Posted
Updated 28-Mar-21 6:10am
v2
Comments
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