Hi peeps...

A good day to all of you yea~ as i know, i can retrieve only the first row by using the keyword limit 1:

select * from tblTesting limit 1

for selecting the first two rows are:

select * from tblTesting [B]limit 2[/B]

is there any solution to getting the second row? not the two rows but is second..

THANKS yea~

The LIMIT directive can take one or two attributes. If you use one attribute, for example "LIMIT 5", it will show only that many records which get taken off of the top of the list of results. If you use two attributes, for example "LIMIT 10, 5", it will skip the number of records indicated by the first number and then show the number of records indicated by the second number. In other words it's "LIMIT skip, show". So to do what you want, execute:

SELECT * FROM tblTesting LIMIT 1, 1

thank you very much exactly what I want

You can only select the second row, or any other row, for a table in any meaningful way if you first sort the table on a given attribute.

For example, you make a database of existing club members, adding them in this order of membership no.

F2
F4
F6
F10
F21
F23
F31
and lots more (ie some previous members have left

Then member F2 leaves the club and you add two new members, F11 and F3.
Who is second in the table? - F6. Second in the data file anyway.
Who did you actually want from the table???

what if old member F2 now rejoins - where does he go in the table? Does his old data get marked as now to be used, or is he stuck on at the end of the table? He is at the end of the table, unless you have an attribute such as currentMember y/n, in which case he is now back where he was. The physical storage position in the database file is meaningless. The method of storage and place of storage is also not of interest, it is the data itself that should determine who or what you retrieve.

But wait, if you use a currentMember y/n field, then when F2 leaves, he is STILL at the top of the data file, so the second in the table is still F4, even though F2 is not a member.

what if you had entered the members in alphabetical order initially...

See what I mean about physical location in the datafile being meaningless?

postgres: SELECT * FROM users LIMIT 1 OFFSET 1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.