LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-26-2008, 05:59 AM   #1
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
Mysql - How to get each line by primary key one by one


if i have a table which has field like "primary key, name, colour" and i want to select all the lines which have the same key, but one by one sequentially (i want them all to appear on separate pages of a website, with a "next one" button), what do i do?
 
Old 07-26-2008, 07:31 AM   #2
Clemente
Member
 
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Rep: Reputation: 30
Hi,

what program language do you use to generate your sites?

I assume, that the "primary key" you mentioned is not the primary key used in the table you query, but any other table. If not, I don't think that your layout would work since all primary keys of any table must be unique... I call the primary key of the table queried "real primary key".

What I would do is
1)
fetching all real primary keys of the lines I am interested in and store it in any session variable. This way, I know how many sites to generate etc. I can show a "this is page 3 of 343", e.g.
2)
query the database on each site request using the primary key stored in the session variable. ("select * fro mytable where id=$currentid")

Or:
1) fetching all queries within one large query and use it as session variable over all site requests.
No not really. I would do what written above...

Greet-o-mente
 
Old 07-27-2008, 05:13 AM   #3
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Original Poster
Rep: Reputation: 62
sorry what's all this about session variables? i think i'll be using perl.
(yes, its the primary key of another table, sorry )
 
Old 07-27-2008, 05:15 AM   #4
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Original Poster
Rep: Reputation: 62
sorry what's all this about session variables? i think i'll be using perl.
(yes, its the primary key of another table, sorry )
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine PRIMARY KEY in mySQL Runnerdave Programming 3 07-11-2006 12:51 PM
SQL - getting the primary key autogenerated of an INSERT statement vharishankar Programming 3 12-05-2005 02:47 AM
gpg primary key doctor_sniff Linux - Software 3 06-11-2005 09:55 AM
Bad Key / No Key Error MySql wasabi Linux - Software 1 04-19-2005 06:06 PM
multiple primary key on gpg carboncopy Linux - Software 2 12-21-2004 08:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration