Hi,
I have a table with 3 columns, something like...
NAME, VALUE, DATE, (String(255), int(11), int(11)).
And for argument lets say the data is
row[0] = "A", 10, 1076968526
row[1] = "A", 10, 1076710733
row[2] = "A", 10, 1076709644
I want to update the row where the name = "A" and set the value to 11. But i
only want to update the latest date, (row[0]), in this case where DATE is
the higher.
How would i run a query to update a row where one on the value is the
highest.
Many thanks
Sims 2 2068
On Tue, 17 Feb 2004 07:44:10 +0200, "Sims" <si*********@hotmail.com>
wrote: Hi,
I have a table with 3 columns, something like...
NAME, VALUE, DATE, (String(255), int(11), int(11)).
And for argument lets say the data is
row[0] = "A", 10, 1076968526 row[1] = "A", 10, 1076710733 row[2] = "A", 10, 1076709644
I want to update the row where the name = "A" and set the value to 11. But i only want to update the latest date, (row[0]), in this case where DATE is the higher. How would i run a query to update a row where one on the value is the highest.
According to: http://www.mysql.com/doc/en/UPDATE.html
you should be able to write
update table set value=11 where name='A' order by date desc limit 1
but I haven't tried it.
There is a bit which explains differences in the behaviour of LIMIT
between MySQL versions. Check that carefully for your version.
--
David ( @priz.co.uk )
Each of those records should have a primary key, so after you have read the
record(s) in and decided which one you want to update it is a simple matter
of issuing the following query:
UPDATE table SET value='11' where pkey='value'.
If you will always want to update the record with the latest date then you
can ensure that it is returned as the first row with the following query:
SELECT * FROM table ORDER BY date DESC LIMIT 1
--
Tony Marston http://www.tonymarston.net
"Sims" <si*********@hotmail.com> wrote in message
news:c0*************@ID-162430.news.uni-berlin.de... Hi,
I have a table with 3 columns, something like...
NAME, VALUE, DATE, (String(255), int(11), int(11)).
And for argument lets say the data is
row[0] = "A", 10, 1076968526 row[1] = "A", 10, 1076710733 row[2] = "A", 10, 1076709644
I want to update the row where the name = "A" and set the value to 11. But
i only want to update the latest date, (row[0]), in this case where DATE is the higher. How would i run a query to update a row where one on the value is the highest.
Many thanks
Sims
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: laurie |
last post by:
Hi all,
I'm trying to help out a friend who has inherited a client with a PHP
shopping cart application. Neither of us know PHP, but I've been
muddling my way through, trying to get these old...
|
by: Ken Bush |
last post by:
How can I write an update query that removes part of a field? Like if I
have a field with values such as 8/3/68 (a birthday obviously) and I need
to put values in a new column but I need...
|
by: Ray |
last post by:
Any help? I have two tables. TABLE 1 one which shows all the days of
the year with
(Number)
(date) Each day of the year
(Yes/No)
TABLE 2 with reservation details with
(Autonumber)
|
by: Maxi |
last post by:
There is a lotto system which picks 21 numbers every day out of 80
numbers.
I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21)
Here is the structure and sample data:
...
|
by: aaron.kempf |
last post by:
team
so i have a nice little list in sharepoint.. about 15k items
i've got the simplest little join statement in access; and im trying to
UPDATE the sharepoint list via an access query.
so...
|
by: M. David Johnson |
last post by:
I cannot get my OleDbDataAdapter to update my database
table from my local dataset table. The Knowledge Base
doesn't seem to help - see item 10 below.
I have a Microsoft Access 2000 database...
|
by: cover |
last post by:
I have an input form that passes data when submitted to a second form
to let the user know what they have just entered into the db.
My question comes with using 'update'. I'd like to query the...
|
by: teenagelcruise |
last post by:
hi,
i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote.
<html>
<head>
<meta...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
| | |