ajoo Posted August 26, 2016 Share Posted August 26, 2016 Hi all ! This works fine and returns a row of the result SELECT fd.fname, fd.lname, fd.role, fd.city, fd.cell, fd.email, fd.fid From fd WHERE fd.recruiter = 118 GROUP by fd.role and if I add Limit 1, 10 to this like this :- SELECT fd.fname, fd.lname, fd.role, fd.city, fd.cell, fd.email, fd.fid From fd WHERE fd.recruiter = 118 GROUP by fd.role LIMIT 1, 10 I get 0 rows. . What's going wrong here or is this like normal ?? Thanks all ! Quote Link to comment https://forums.phpfreaks.com/topic/302011-yet-another-query-blues/ Share on other sites More sharing options...
ajoo Posted August 26, 2016 Author Share Posted August 26, 2016 ok so i thought that GROUP by is creating an issue and I removed that from the query. And guess what :- SELECT fd.fname, fd.lname, fd.role, fd.city, fd.cell, fd.email, fd.fid From fd WHERE fd.recruiter = 118 LIMIT 1, 10 still returns an empty set. . If I simply remove the LIMIT 1, 10, I get my row of result. I have never had this sort of problem ?? In fact I use LIMIT in most of my queries. Please someone explain to me what's going on !?? Quote Link to comment https://forums.phpfreaks.com/topic/302011-yet-another-query-blues/#findComment-1536661 Share on other sites More sharing options...
Solution Jacques1 Posted August 26, 2016 Solution Share Posted August 26, 2016 The offset is 0-based, so starting at 1 will skip the only row. A GROUP BY clause only makes sense when you're using an aggregate function like SUM() or AVG(). Quote Link to comment https://forums.phpfreaks.com/topic/302011-yet-another-query-blues/#findComment-1536663 Share on other sites More sharing options...
ajoo Posted August 26, 2016 Author Share Posted August 26, 2016 Hi Guru Jacques !!! Thank you sir, Coincidentally I had just tried the 0 - offset this morning & found it working and also read about the usage of the GROUP since I was unsure of it and I have been using it like thinking it would be a SORT ON kind of function. Thanks Loads ! Quote Link to comment https://forums.phpfreaks.com/topic/302011-yet-another-query-blues/#findComment-1536669 Share on other sites More sharing options...
kicken Posted August 26, 2016 Share Posted August 26, 2016 thinking it would be a SORT ON kind of function. Sorting is done using the ORDER BY clause. Quote Link to comment https://forums.phpfreaks.com/topic/302011-yet-another-query-blues/#findComment-1536674 Share on other sites More sharing options...
ajoo Posted August 26, 2016 Author Share Posted August 26, 2016 Hi Kicken ! yes thanks ! Quote Link to comment https://forums.phpfreaks.com/topic/302011-yet-another-query-blues/#findComment-1536675 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.