Jump to content

[SOLVED] SQL Problem


CaptainChainsaw

Recommended Posts

Hi all,

 

I've got an irratating SQL problem, the following SQL returns 9 rows:

 


SELECT comments.id, comments.comment, users.username FROM comments, movies, users WHERE movies.id=comments.mid AND users.id=comments.uid AND movies.id=10 ORDER BY id DESC LIMIT 6, 9 

 

However the same SQL with the LIMIT clause changed CORRECTLY returns 3 rows:

 


SELECT comments.id, comments.comment, users.username FROM comments, movies, users WHERE movies.id=comments.mid AND users.id=comments.uid AND movies.id=10 ORDER BY id DESC LIMIT 0, 3 

 

Anyone any ideas on this one?

 

 

Thanks again,

 

CC

Link to comment
https://forums.phpfreaks.com/topic/121779-solved-sql-problem/
Share on other sites

the first number is the offset, the second number is the length it should go for.  try this:

 

LIMIT 6, 3

 

i made that mistake when i was first learning too.  the two numbers aren't start/stop offsets.  have a peek in the MySQL manual for more details.

Link to comment
https://forums.phpfreaks.com/topic/121779-solved-sql-problem/#findComment-628278
Share on other sites

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.