Gorm native sql gets the number of returned messages

I would like to ask you a question about gorm. How does the data queried by raw know the total number of entries before LIMIT, which is used for pagination
db.Db.Offset (offset) .Limit (limit) .Raw ("sql"). Scan (& result.SubjectListResult). Count (& result.Count)

count can"t get it at the end
there is only one line of scan prompt in front of scan

the temporary solution now is to SELECT count (1) check again

Oct.29,2021

r := db.Db.Offset(offset).Limit(limit).Raw("sql").Scan(&result.SubjectListResult).RowsAffected

r is the number of records returned by your query. Besides, isn't your result.SubjectListResult just a slice, just len (result.SubjectListResult) directly?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b356a5-4051c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b356a5-4051c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?