Page 1 of 1
SELECT TOP
Posted: Mon Mar 10, 2003 10:59 am
by nmotion
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 ?
Posted: Mon Mar 10, 2003 11:20 am
by daven
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.
It works but
Posted: Mon Mar 10, 2003 12:05 pm
by nmotion
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.