View Full Version : mySQL problem with LIMIT
jeffryan
03-14-2002, 06:19 PM
I am not all that familiar with using SQL in mySQL, I see that in phpMyAdmin that the result pages are automatically limited with the syntax "limit 0, 30" or whatever the offset is. I'm trying to do this with my own query, and its not working.
I am on the phpMyAdmin database home page and am copy/pasting code into the Run SQL area, but it won't work. It comes back with an error, but does not have an error message.
Even doing something as simple as this:
Select *
From Mydatabase limit 1, 20
brings the same problem.
Is this disabled for general use or somethign?:cool:
Stewart
03-14-2002, 06:34 PM
hmm, you have to have a table to select from, not the database.
ie:
SELECT * FROM tablename LIMIT 1, 20
jeffryan
03-14-2002, 06:40 PM
My mistake.
I am doing
Select *
From tablename limit 0, 30
Actually I am just copy/pasting the query that is listed from my browse command in the phpMyAdmin exactly as is displayed and it won't do it from the SQL Query area.
Stewart
03-14-2002, 06:50 PM
hmmmm.
i usually only use the run query box to insert tables and data into the db.
what i think phpmyadmin does, is to add the "LIMIT 0, 30" bit on the end automatically.
just type in "SELECT * FROM tablename", and you will see it will work!
jeffryan
03-14-2002, 08:38 PM
"Select * From Tablename" does work
What I am getting at is I am trying to do a query where I only want the first 5 records, so I was trying to use the LIMIT function.
But can not get it to work. It won't work in the SQL query window, and it doesn't work for me on my pages. I have other queries that work, when I go to add "limit 1, 20" or "LIMIT 1, 20" or even "limit 5" the query just does not work.
That has been my problem. It seems like I am doing it right and it just doesn't want to work for me.
jeffryan
03-15-2002, 12:18 PM
Can someone verify that they can do a limit query on the servers?
Just want to make sure there is not something being blocked or that is broken. The query is so short and simple that I can't see how there could be any problem with it.
I can not do a limit in the phpMyAdmin or on a webpage. Other queries work fine.
middleground
03-16-2002, 05:46 PM
The number of rows to bring back in phpMyAdmin is a config file setting, so I doubt you'll be able to override without going into the php code.
Since you cannot access that on HR- you are probably stuck with what they give you.
mysql> select * from jcn;
+-----+
| id |
+-----+
| 578 |
| 579 |
| 580 |
| 581 |
| 582 |
+-----+
5 rows in set (0.00 sec)
mysql> select * from jcn limit 2;'
+-----+
| id |
+-----+
| 578 |
| 579 |
+-----+
2 rows in set (0.00 sec)
middleground
03-16-2002, 06:27 PM
Sorry- I thought he meant going through phpMyAdmin
Jim Dam
03-16-2002, 08:34 PM
Are you in a database when you do that?
If not, select a database to work in with this command:
USE dbname;
or put the database name in the SELECT command:
SELECT * FROM dbname.tablename;
Once you get results from selecting the rows, then try adding LIMIT.
If you are doing this, then disregard this post :p
Also, maybe copy the SQL you are using and the output to see if anyone here can tell what's wrong.
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.