BillRayDrums Posted May 14, 2011 Share Posted May 14, 2011 Hi, I'm kinda a newbie to MySQL. I have a query that works, but am trying to now limit the results returned. Here's the query: SELECT c.avatar, c.user_id, u.id, c.cb_currentgig, u.username, u.name, c.cb_currentgig, u.usertype FROM #__comprofiler AS c, #__users AS u WHERE c.user_id = u.id AND u.usertype = 'author' AND c.confirmed = '1' AND c.approved = '1' AND c.banned = '0' AND u.block = '0' AND c.avatar NOT LIKE 'NULL' ORDER BY lastupdatedate DESC How do I make the limit work? I've tried everything that was given to me and it doesn't return anything if I add the LIMIT statement. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/236421-limiting-the-number-of-results-returned/ Share on other sites More sharing options...
HDFilmMaker2112 Posted May 14, 2011 Share Posted May 14, 2011 Well first, do you have any more column in those tables, because I'd just use * instead of calling each individual column. SELECT * FROM #__comprofiler AS c, #__users AS u WHERE (c.user_id = u.id, c.confirmed = '1', c.approved = '1', c.banned = '0', c.avatar NOT LIKE 'NULL'),(u.usertype = 'author', u.block = '0') ORDER BY lastupdatedate DESC Try that with adding the LIMIT after. I maybe off, as this is not my strongest coding area, but if somebody else doesn't answer for a while, it's at least worth a try. Quote Link to comment https://forums.phpfreaks.com/topic/236421-limiting-the-number-of-results-returned/#findComment-1215495 Share on other sites More sharing options...
Pikachu2000 Posted May 14, 2011 Share Posted May 14, 2011 You shouldn't use SELECT *, actually. You're better off to list the fields explicitly. You say your LIMIT clause craters the query, but you didn't post it. Post it with the query string exactly as it is when it creates the problem, along with any error messages it generates. Quote Link to comment https://forums.phpfreaks.com/topic/236421-limiting-the-number-of-results-returned/#findComment-1215537 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.