Jump to content

Limiting the number of results returned


BillRayDrums

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:

 

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!

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/236421-limiting-the-number-of-results-returned/
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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.