Greetings I made a following table named block_userlist
containing login and logout statistics:
+------------------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------------+------+-----+---------+----------------+
| id | bigint(10) | NO | PRI | NULL | auto_increment |
| user_id | bigint(10) | NO | | NULL | |
| logout_time | bigint(10) | YES | | NULL | |
| login_time | bigint(10) | NO | | NULL | |
| session_duration | bigint(10) | YES | | NULL | |
+------------------+------------+------+-----+---------+----------------+
And on my rdbms when I try to fetch it like that:
SELECT user.username,login_time,logout_time,FROM_UNIXTIME(session_duration) FROM user JOIN block_userlist on user.id=block_userlist.user_id ORDER BY login_time DESC;
The results are fetched correctly but when I try it via get_records_sql
I want to fetch the data even if I get duplicate values on username field. Because on my moodle custom block I get the following error:
Did you remember to make the first column something unique in your call to get_records? Duplicate value 'admin' found in column 'username'.
So I want to know how I can fetch duplicate values from my database in queries like thar? In my block's logic is acceptable to fetch duplicate values.