Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit SQL statement

Status
Not open for further replies.

TTA23

MIS
Sep 26, 2006
41
US
I have a statement :


select * from T_Adherent limit 1, 10 where ....

It seems to be wrong.

Is there a way to have the limit statement followed by a where statement. If not how can I limit the query with a where statement?
thanks
 
here is the sequence of clauses ...

[tt] SELECT ...
FROM ...
WHERE ...
GROUP BY ...
HAVING ...
ORDER BY ...
LIMIT ...[/tt]

you are not allowed to put the LIMIT clause just anywhere, it has to go in its proper place

:)

r937.com | rudy.ca
 
as said by r937 each clause has its place.

If you want a Where clause, place it before the limit clause:


Code:
select * from T_Adherent [red]WHERE...[/red] LIMIT 1,10

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thank.
I am using ASP, and this is my first using PHP..... and MYSQL
 
i think that you will find the sequence of the clauses in a SELECT statement is the same in every database system

:)

r937.com | rudy.ca
 
r937-
You are right, I just checked that I can use the Limit statement for my other db in ASp. Never have to use it before and I thought this have to do with MySql or PHP.
Thanks again.
 
MSSQL / Pervasive / VMS or DB2. Those are the ones I usually work with. This MYSQL is a first attempt to learn a little PHP
 
Personnally PHP doesn't give me anything better than I have now. It is just interresting to see how it works, but a lot of work when I do not know all the little ways around.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top