PHP display duplicate record

0

Recently I started developing in PHP + MySQL, I'm doubtful about displaying the query, scenario follows. I am doing select with 3 tables mdl_logstore_standard , mdl_course and mdl_user , where in the mdl_logstore_standard table contains FK of mdl_course (courseid) and table mdl_user (userid), when I execute query in console of the database returns all records (including duplicates), but when I debug in PHP it returns the records without duplicates.

I would like to return all records including duplicates:

Query:

SELECT u.firstname AS 'USUARIO',
   u.department AS 'DEPARTAMENTO', 
   l.id AS 'ID_LOG', 
   eventname, action, FROM_UNIXTIME(l.timecreated),
   l.courseid as 'COD_CURSO', 
   c.id AS 'ID CURSO mdl_course',
c.fullname AS 'DESCRICAO CURSO'   
FROM mdl_logstore_standard_log l,
   mdl_course c,
   mdl_user u  
WHERE    
   l.courseid = c.id AND l.userid =  u.id 
ORDER BY l.timecreated DESC LIMIT 50

PHP.

 $sql ="SELECT u.firstname AS 'USUARIO',
        u.department AS 'DEPARTAMENTO', 
        l.id AS 'ID_LOG',   
        eventname, action, FROM_UNIXTIME(l.timecreated),   
        l.courseid as 'COD_CURSO', c.id AS 'ID CURSO mdl_course',   
        c.fullname AS 'DESCRICAO CURSO'   
        FROM   mdl_logstore_standard_log l,mdl_course c , mdl_user u  
        WHERE l.courseid = c.id   AND  l.userid =  u.id 
        ORDER BY l.timecreated DESC LIMIT 50";

Query execution:

$start_consulta = $DB->get_records_sql($sql);

Query view:

echo "<pre>";
print_r ($start_consulta); 
echo "</pre>";
    
asked by anonymous 13.03.2017 / 21:06

0 answers