Mysql - How to get each line by primary key one by one
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.