I'm used to code in ASP and MS SQL server. I use SQL like "SELECT TOP 10 " but in PHP the TOP code doesn't seem to work.
Is this true ?
SELECT TOP
Moderator: General Moderators
- daven
- Forum Contributor
- Posts: 332
- Joined: Tue Dec 17, 2002 1:29 pm
- Location: Gaithersburg, MD
- Contact:
The TOP command is a database dependent thing, not PHP. MySQL does not use TOP, instead it uses LIMIT.
ex1: SELECT * FROM Table LIMIT 10 // select first 10 rows
ex2: SELECT * FROM Table LIMIT 5,15 // select rows 6-20 (offset 5, limit 15)
I am unsure as to what the command is for PostGRESQL, if you are using that db. Just check the docs.
ex1: SELECT * FROM Table LIMIT 10 // select first 10 rows
ex2: SELECT * FROM Table LIMIT 5,15 // select rows 6-20 (offset 5, limit 15)
I am unsure as to what the command is for PostGRESQL, if you are using that db. Just check the docs.
It works but
Thanks, I use MySQL and your tip works.
There is just a little but... Is it me or does this seem slow like it is looking trough a lot of rows and first at the end limit it to say 2 rows.
There is just a little but... Is it me or does this seem slow like it is looking trough a lot of rows and first at the end limit it to say 2 rows.