hi,
i want to display the five most recent rows in my table (there is a
timestamp), but sorted in ascending order.
the problem is that when i call
SELECT * FROM spam ORDER BY time ASC LIMIT 5
it shows the first five entries in ascending order, but i want the last
five.
needless to say, it works fine with descending order..
thanks. 6 6000
Mark wrote:
hi,
i want to display the five most recent rows in my table (there is a
timestamp), but sorted in ascending order.
the problem is that when i call
SELECT * FROM spam ORDER BY time ASC LIMIT 5
it shows the first five entries in ascending order, but i want the last
five.
needless to say, it works fine with descending order..
thanks.
Do you want first five entrys in descending order or last five entrys
in ascending order or what ????
Mark wrote:
hi,
i want to display the five most recent rows in my table (there is a
timestamp), but sorted in ascending order.
the problem is that when i call
SELECT * FROM spam ORDER BY time ASC LIMIT 5
it shows the first five entries in ascending order, but i want the last
five.
needless to say, it works fine with descending order..
thanks.
SELECT * FROM (SELECT * FROM spam ORDER BY time DESC LIMIT 5) t1 ORDER
BY time ASC;
strawberry wrote:
Mark wrote:
hi,
i want to display the five most recent rows in my table (there is a
timestamp), but sorted in ascending order.
the problem is that when i call
SELECT * FROM spam ORDER BY time ASC LIMIT 5
it shows the first five entries in ascending order, but i want the last
five.
needless to say, it works fine with descending order..
thanks.
SELECT * FROM (SELECT * FROM spam ORDER BY time DESC LIMIT 5) t1 ORDER
BY time ASC;
SELECT * FROM (SELECT * FROM spam LEFT JOIN users USING (user_id) ORDER
BY time DESC LIMIT $view) t1 ORDER BY time ASC
wow..it works. that's so ugly :p
thank you so much!
but what does this "t1" mean?
"Mark" <mn*******@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
>
strawberry wrote:
>Mark wrote:
hi,
i want to display the five most recent rows in my table (there is a
timestamp), but sorted in ascending order.
the problem is that when i call
SELECT * FROM spam ORDER BY time ASC LIMIT 5
it shows the first five entries in ascending order, but i want the last
five.
needless to say, it works fine with descending order..
thanks.
SELECT * FROM (SELECT * FROM spam ORDER BY time DESC LIMIT 5) t1 ORDER BY time ASC;
SELECT * FROM (SELECT * FROM spam LEFT JOIN users USING (user_id) ORDER
BY time DESC LIMIT $view) t1 ORDER BY time ASC
wow..it works. that's so ugly :p
thank you so much!
but what does this "t1" mean?
It's just aliasing the return set and is required for syntax correctness I
believe.
Jim Langston wrote:
>but what does this "t1" mean?
It's just aliasing the return set and is required for syntax correctness I
believe.
Right. Technically, it's called a "correlation name". It's required
when you use a subquery as a derived table in the FROM clause, because
otherwise how would you refer to columns from that derived table?
SELECT foo FROM table1, (SELECT foo FROM table2);
Does the above retrieve foo from table1 or foo from table2? To resolve
the ambiguity, we use correlation names:
SELECT t1.foo FROM table1 AS t1, (SELECT foo FROM table2) AS t2
Regards,
Bill K.
Bill Karwin wrote:
Jim Langston wrote:
but what does this "t1" mean?
It's just aliasing the return set and is required for syntax correctness I
believe.
Right. Technically, it's called a "correlation name". It's required
when you use a subquery as a derived table in the FROM clause, because
otherwise how would you refer to columns from that derived table?
SELECT foo FROM table1, (SELECT foo FROM table2);
Does the above retrieve foo from table1 or foo from table2? To resolve
the ambiguity, we use correlation names:
SELECT t1.foo FROM table1 AS t1, (SELECT foo FROM table2) AS t2
Regards,
Bill K.
i see. i thought it had to do with naming, but as far as i can see "t1"
was never referenced, so i was wondering why it was necessary. but i
guess for syntax's sake.. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mark |
last post by:
Hi yall
I'm a newbie, forgive me...
I am sure I have seen a simple way to do this, but I can't for the life of
me remember how it was done...
Say there is a database of jokes, from...
|
by: Brian McGonigle |
last post by:
I'm a Perl programmer learning Python (up to chapter 7 in Learning
Python, so go easy on me :-) and I find that I look to do things in
Python the way I would do them in Perl. In Perl functions and...
|
by: Nova's Taylor |
last post by:
Hi folks,
I am a newbie to Python and am hoping that someone can get me started
on a log parser that I am trying to write.
The log is an ASCII file that contains a process identifier (PID),...
|
by: googleboy |
last post by:
I didn't think this would be as difficult as it now seems to me.
I am reading in a csv file that documents a bunch of different info on
about 200 books, such as title, author, publisher, isbn,...
|
by: Jake |
last post by:
Im using the following code to display the contents of a directory:
<%
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFiles = objFso.GetFolder(Server.MapPath("."))
Set fileList...
|
by: Gary |
last post by:
Does anyone know how to do a sort to find the most recent distinct records.
We have records with equipment, and activities the equipment was used for,
but I need a distinct list of where the...
|
by: bissatch |
last post by:
Hi,
I am about to create a table, where the values are taken from an XML
file, where each column header you can click and it will sort the table
rows at the client side.
I have got to the...
|
by: Robert Wille |
last post by:
I have found that the sort order is different on Windows and Linux (same version of Postgres). On Windows, it sorts in what appears to be normal ASCIIorder. On Linux, lowercase comes before...
|
by: Shi Mu |
last post by:
I have a list like ,,,]. How can I sort the list
based on the second value in the item?
That is,
I want the list to be:
,,,]
|
by: Peter Olcott |
last post by:
I have used the standard template library quite a bit, and std::sort has been
very useful. Now I have reached the point where my memory requirements are
exceeded. Is there some standard way to sort...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |