I have two tables joined called user
and records
with the structure below. With query below, i am trying to get users with status
= 1 who have hours or seconds > 0. When i run the query, it gives me user 142
who has status 0.
The query actually returns the two rows in the user table. It should return just one row.. i.e user 199
What is wrong with my query please ?
user
id status
199 1
142 0
records
user_id hours seconds
199 10 90
144 0 800
Controller
$results = array();
$results = $this->db->query("SELECT user.id, user.status, records.hours, records.seconds
from user
INNER JOIN records
ON user.id = records.user_id
WHERE user.status = 1
and records.hours
or records.seconds > 0 ");
$get_results = $results->result_array();
return $get_results;