News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SQL question

Started by Biology Forums, June 11, 2018, 12:18:25 PM

Previous topic - Next topic

Biology Forums

Hi everyone,

Say I have a table with many rows, and I wanted to limit the query between rows 10,000 and 20,000 or 300 to 400, how would I change the LIMIT part to reflect that?

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

albertlast



Biology Forums

Quote from: vbgamer45 on June 11, 2018, 01:03:51 PM
LIMIT 10000, 20000


Are you sure this will give me 10000 rows? I.e. 20,000 - 10,000 = 10,000?

Please when I write $count = mysql_num_rows($request); it gives me 20,000. I need the difference

vbgamer45

No it doesn't it should be
LIMIT 10000, 10000

Since the first returns 20k records

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Biology Forums

Maybe I'm not communicating what I want very well.

I'll try again. Pretend I want rows between 30 and 40. In other words, I want 10 row output between row 30 and 40, would I use

LIMIT 30, 40? I tried that already and it didn't work.

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

vbgamer45

Normally I use id's to return the rows i want rather than limit offsets. Limits i generally use with paging

Such as where id_msg >= 30 and id_msg <= 40
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Biology Forums

Quote from: vbgamer45 on June 13, 2018, 09:28:17 AM
Normally I use id's to return the rows i want rather than limit offsets. Limits i generally use with paging

Such as where id_msg >= 30 and id_msg <= 40


This works best for my needs, thanks for the idea.

vbgamer45

That is always the most efficient way as well.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Advertisement: