Private Label and Cobranded VoIP Solutions
BrainCast internet & phone based message/memo recording & reminder organization system
Internet Phone Service and Broadband Phone Service by ViaTalk

Go Back   VoIP Forums, Internet Phone Service Forums, & Web Hosting Forums > CoderForums - Programming Discussion > General Programming Issues > Programming Languages & Technologies > PHP

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-14-2002, 06:19 PM
jeffryan jeffryan is offline
Registered User
 
Join Date: Mar 2002
Posts: 4
mySQL problem with LIMIT

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?
Reply With Quote
  #2  
Old 03-14-2002, 06:34 PM
Stewart's Avatar
Stewart Stewart is offline
That's me!
 
Join Date: Jun 2001
Location: UK
Posts: 376
hmm, you have to have a table to select from, not the database.

ie:

SELECT * FROM tablename LIMIT 1, 20
__________________
Stewart Whiting

Need computer or network help? Come to http://www.coreworldstech.com
Reply With Quote
  #3  
Old 03-14-2002, 06:40 PM
jeffryan jeffryan is offline
Registered User
 
Join Date: Mar 2002
Posts: 4
Error

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.
Reply With Quote
  #4  
Old 03-14-2002, 06:50 PM
Stewart's Avatar
Stewart Stewart is offline
That's me!
 
Join Date: Jun 2001
Location: UK
Posts: 376
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!
__________________
Stewart Whiting

Need computer or network help? Come to http://www.coreworldstech.com
Reply With Quote
  #5  
Old 03-14-2002, 08:38 PM
jeffryan jeffryan is offline
Registered User
 
Join Date: Mar 2002
Posts: 4
That works

"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.
Reply With Quote
  #6  
Old 03-15-2002, 12:18 PM
jeffryan jeffryan is offline
Registered User
 
Join Date: Mar 2002
Posts: 4
Verify

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.
Reply With Quote
  #7  
Old 03-16-2002, 05:46 PM
middleground's Avatar
middleground middleground is offline
Registered User
 
Join Date: Oct 2001
Location: Pa
Posts: 127
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.
__________________
Every Day Above Ground Is A Good One!!!
Reply With Quote
  #8  
Old 03-16-2002, 06:13 PM
JoeF JoeF is offline
QL User
 
Join Date: Jan 2002
Posts: 71
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)
__________________
--
Joe F
Reply With Quote
  #9  
Old 03-16-2002, 06:27 PM
middleground's Avatar
middleground middleground is offline
Registered User
 
Join Date: Oct 2001
Location: Pa
Posts: 127
Sorry- I thought he meant going through phpMyAdmin
__________________
Every Day Above Ground Is A Good One!!!
Reply With Quote
  #10  
Old 03-16-2002, 08:34 PM
Jim Dam Jim Dam is offline
Registered User
 
Join Date: Mar 2002
Posts: 11
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

Also, maybe copy the SQL you are using and the output to see if anyone here can tell what's wrong.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump