Hi,
I have a list of product orders in a table with the following structure :
OrderID
ProductID
OrderDate
OrderCost
What query would I need to get the last order for each productID ?
Cheers,
Neil
[snip]
I have a list of product orders in a table with the following structure
:
OrderID
ProductID
OrderDate
OrderCost
What query would I need to get the last order for each productID ?
[/snip]
MAX(OrderDate)
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To
SELECT ProductID, MAX(OrderDate) FROM table GROUP BY ProductID;
or if you want all the columns
SELECT * FROM table a, (SELECT ProductID, MAX(OrderDate) as MaxDate FROM
table GROUP BY ProductID) as b WHERE a.ProductID = b.ProductID AND
a.OrderDate = b.MaxDate;
Tompkins Neil wrote:
Hi,
I
290248558
119939485 0 NULL
2289391143430290AN122001697436588
20836217840 NULL
I am trying to read the last record for each column for a given day
(when the stats are input they are already a sum, so the last entry
will be the cumulative total for each day
-- Forwarded message --
From: sheeri kritzer [EMAIL PROTECTED]
Date: Mar 27, 2006 1:18 PM
Subject: Re: Insuring select returns the last record for a given day.
To: Paul Halliday [EMAIL PROTECTED]
I have a similar table, so I tried out your query on the table I have:
select
I'm interesting to know what is the best way to select last inserted record.
This can do it ORDER BY id desc limit 5 .. but ..
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
[snip]
I'm interesting to know what is the best way to select last inserted
record.
This can do it ORDER BY id desc limit 5 .. but ..
[/snip]
That is generally best, but if you have an auto-increment field
SELECT MAX(auto-increment field), * FROM `table`
--
MySQL General Mailing List
For
I am having more than 10 records in a table. I want to select only first top 10
records (depending on one field score) and then want to select 10th position record.
select * from table1 order by score desc LIMIT 10
This will give me 10 records but then how to get the last record ?
Thanks
This will give me 10 records but then how to get the last record ?
order by score asc limit 1
[i.e. turn it around and pick the 1st (which will be the last because it's
ordered the other way)]
:-)
-Kp
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http
I am having more than 10 records in a table. I want to select only first
top 10 records (depending on one field score) and then want to select 10th
position record.
select * from table1 order by score desc LIMIT 10
This will give me 10 records but then how to get the last record ?
Cycle them
[EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, August 23, 2004 8:34 PM
Subject: Re: How to get the last record from the slected record set
--On 22 August 2004 20:31 +0800 Manisha Sathe [EMAIL PROTECTED]
wrote:
I am having more than 10 records in a table. I want to select only first
top 10
yes, but is there any better way of doing it ?
regards
Manisha
- Original Message -
From: Karl Pielorz [EMAIL PROTECTED]
To: Manisha Sathe [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, August 23, 2004 8:34 PM
Subject: Re: How to get the last record from the slected record set
* Manisha Sathe
I want to select first 10 records out of 100. And then get the 10th
position.
If i make use of
order by score asc limit 1
then I will get 100th record, How shall i pick up 10th position?
Try this:
order by score desc LIMIT 9,1
--
Roger
--
MySQL General Mailing
Manisha Sathe wrote:
I want to select first 10 records out of 100. And then get the 10th
position.
If i make use of
order by score asc limit 1
then I will get 100th record, How shall i pick up 10th position?
regards
Manisha
order by score desc limit 9,1
--
MySQL General Mailing List
For list
--On 22 August 2004 21:05 +0800 Manisha Sathe [EMAIL PROTECTED]
wrote:
I want to select first 10 records out of 100. And then get the 10th
position.
If i make use of
order by score asc limit 1
then I will get 100th record, How shall i pick up 10th position?
I'm not quite sure I follow what
with the DB components I can simply tell the
Navigator to get the last record. Fairly straight forward. I have recently
found that using the DB componensts (so I am told) creates a local dataset
which means that ALL rows selected are transferred to a local dataset for
you to have a simple goto last record
Thanks to all of, I could get it
Thanks
Manisha
- Original Message -
From: Karl Pielorz [EMAIL PROTECTED]
To: Manisha Sathe [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, August 23, 2004 9:52 PM
Subject: Re: How to get the last record from the slected record set
--On 22
Hello,
what is the most effecient way to query the last record in a table, if querying
the primary key(acctid) column ??
I've tried select *,max(acctid) as lastid from subscribers where acctid =
'lastid' group by acctid
but this returns nothing ??
TIA :)
--
MikemickaloBlezien
At 13:52 -0500 7/5/04, Mike Blezien wrote:
Hello,
what is the most effecient way to query the last record in a table,
if querying the primary key(acctid) column ??
What do you mean by last? The row containing the largest acctid value?
You might try ... ORDER BY acctid DESC LIMIT 1.
I've tried
cancel this, found my problem :) this query worked:
SELECT * FROM subscribers ORDER BY acctid DESC LIMIT 1
Original Message
Subject: Query last record in table
Date: Mon, 05 Jul 2004 13:52:28 -0500
From: Mike Blezien [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
Organization
Hi Tia,
I'm not sure, but my old SQL trick was to do a select * top 1 from
subscribers order by acctid desc
Scotty.
-Original Message-
From: Mike Blezien [mailto:[EMAIL PROTECTED]
Sent: July 5, 2004 2:52 PM
To: MySQL List
Subject: Query last record in table
Hello,
what is the most
I'm trying to select the last record (row) in a db. I'm trying with a
select:
Select * from job_log_2004 where job_log_2004.JobID = (select
max(job_log_2004.JobID) from job_log_2004) and it fails. The part about
select max works and returns a number. What on earth am I doing wrong
[mailto:[EMAIL PROTECTED]
Sent: Thursday, April 22, 2004 12:43 PM
To: [EMAIL PROTECTED]
Subject: Last Record Pulling my hair out :D
I'm trying to select the last record (row) in a db. I'm trying with a
select:
Select * from job_log_2004 where job_log_2004.JobID = (select
max(job_log_2004.JobID
Think you want:
Select max(job_id)
from job_log_2004
I'm trying to select the last record (row) in a db. I'm trying with a
select:
Select * from job_log_2004 where job_log_2004.JobID = (select
max(job_log_2004.JobID) from job_log_2004) and it fails. The part about
select max works
John M,
Thanks for the solution, gave me exactly what I was looking for.
Thanks,
James
-Original Message-
From: John McCaskey [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 22, 2004 3:54 PM
To: James; [EMAIL PROTECTED]
Subject: RE: Last Record Pulling my hair out :D
Try, SELECT
An: mysql
Betreff: retrieving last record for all distinct users
I have a table SESSIONS with the following fields:
SESSION_ID LOGIN IP TIMESTAMP
I am trying to select the last login record for all distinct users. The
closest
I can get to is:
select distinct LOGIN
Message-
From: motorpsychkill [mailto:[EMAIL PROTECTED]
Sent: 20 March 2004 01:18
To: mysql
Subject: retrieving last record for all distinct users
I have a table SESSIONS with the following fields:
SESSION_ID LOGIN IP TIMESTAMP
I am trying to select
: retrieving last record for all distinct users
Making the assumption that you are running a version of MySQL which supports
subqueries, I believe you could use:
SELECT Login, TimeStamp, IP
FROMSessions S
INNER JOIN (
SELECT MAX(TimeStamp) TimeStamp, Login
I have a table SESSIONS with the following fields:
SESSION_ID LOGIN IP TIMESTAMP
I am trying to select the last login record for all distinct users. The
closest
I can get to is:
select distinct LOGIN, TIMESTAMP, IP from SESSIONS group by LOGIN order by
First, since you group by LOGIN, you don't need DISTINCT.
The problem is that GROUP BY is designed for use with aggregate functions,
not individual rows. So which values of SESSION_ID, IP, and TIMESTAMP you
should get is undefined. The manual gives 3 solutions to this problem:
Hi:
How Can I do for after a query I put at the its last record?
Thanks in advance
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On Monday 09 February 2004 08:44, Patricio Gigoux wrote:
Hi:
How Can I do for after a query I put at the its last record?
I'm not sure I followed the question, but I think you're asking how to look at
the last record in the set you just returned
]
Sent: Monday, February 09, 2004 10:29 AM
Subject: Re: Last record
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On Monday 09 February 2004 08:44, Patricio Gigoux wrote:
Hi:
How Can I do for after a query I put at the its last record?
I'm not sure I followed the question, but I think you're
Being real new to MySQL I am having difficulty finding information on how to
retrieve data from the last record in a database.
I have tried using the SELECT LAST_INSERT_ID() statement but that only works
on a per connection basis and doesn't help all the times.
Basically I want to goto the end
Hi Jess,
Being real new to MySQL I am having difficulty finding information on how
to
retrieve data from the last record in a database.
Mind you - the last record doesn't have to be the last record if you're
running an application with multiple users.
That said, the last record in any table
:
Subject: Finding information in the
last record
10/29/2003 10:50
* Deependra b. Tandukar
How do I select the very last record in a column in MySQL database?
The expression last record implies that there is an ORDER in your query...
if you add the keyword DESC and a LIMIT 1, you should get the desired
result:
SELECT *
FROM mytable
ORDER BY mycolumn DESC
On 11 Feb 2003, at 10:30, Deependra b. Tandukar wrote:
How do I select the very last record in a column in MySQL database?
That depends on what you mean by last record. What are you sorting
by? Once you've figured that out, do a query like this:
SELECT * FROM table_name
ORDER
Dear all,
How do I select the very last record in a column in MySQL database?
Regards,
DT
-
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive
Dear all,
How do I select the very last record in a column in MySQL database?
Regards,
DT
-
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list
Message -
From: "Arjen Lentz" [EMAIL PROTECTED]
To: "kayamboo" [EMAIL PROTECTED]
Cc: "list mysql" [EMAIL PROTECTED]
Sent: Thursday, October 10, 2002 1:08 PM
Subject: Re: password / last record
Hi,
On Thu, 2002-10-10 at 10:57, kayamboo wrote:
1. Is there a
sql, query
Hello Folks
1. Is there anyway to know the string value of the password using the
encrypted value , from the mysql.user table ?
2. How can I know the most recently entered record, that does not have an
AUTOINCREMENT column ?
Thanks for the tips.
Hi,
On Thu, 2002-10-10 at 10:57, kayamboo wrote:
1. Is there anyway to know the string value of the password using the
encrypted value , from the mysql.user table ?
No. It's scrambled with a one-way (lossy) algorithm.
2. How can I know the most recently entered record, that does not
Hello! :)
Is there any chance to select last record in one sql
statement?
Thanks.
Kosyo
__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
[snip]
Is there any chance to select last record in one sql
statement?
[/snip]
Try this query;
SELECT *
FROM tableName
ORDER BY id DESC
LIMIT 1
HTH!
Jay
-
Before posting, please check:
http://www.mysql.com/manual.php
Dear,
I decided to collect data into MySQL for realtime display usage. How
could I know there are new records add to table and retrieve them to
display? Is there different to do this with VB (Client/Server style) and
PHP (Web Bases Style)?
Thanks
Sommai Fongnamthip
46 matches
Mail list logo