Jump to content

Limiting the number of results returned


Recommended Posts

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:













#__comprofiler AS c,

#__users AS u



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.







Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.