Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





SUM Of The Amounts And The Last Updated DATE


I got the following table details. I need the query to return the SUM of the amount column with the last updated DATE

I have written the following query to make this happen.. but ....




View Complete Forum Thread with Replies

Related Forum Messages:
Date Table Last Updated
In phpmyadmin it shows a date and time that the table was last updated – is it possible to retrieve this information?

View Replies !
Recording The Date A Particular Field Is Updated
I have a table, which has LastUpdated field that records when a record is updated.

This is mainly being used to enable the site owner to send out email shots like so :

1. An email address is added to a record, and records the date.

2. At the end of the day, a search is carried out for that date.

3. A list of contacts updated (had an email address added) that day is returned.

4. They click through to a compose email page, which in the background updated an EmailList field fron N to Y.

5. The email is sent to contacts where EmailList=Y.

6. A button at the end resets the EmailList field back to N for the next time its used.

Which all works great, but we've had a couple of issues where users haven't quite appreciated what is happening, and have managed to return all contacts in error, update the EmailList for them all to Y, then abort the process midway, without completing the step which resets that field back back to N.

So... what I think would resolve this is to have an EmailAddressUpdated field which records when the EmailAddress field is updated, rather than the existing general LastUpdated field which records when the record is updated in any way.

View Replies !
Testing The Updated Database Whether It Is Properly Updated Or Not
After updating the large database with large sets of data (usually from tab delimited files and by programs). How do I check the database whether it is properly updated or not? .Since if there is a subtle error in tab delimited files will lead to improper update of the tables with NULL fields. I have to check the database for NULL fields and whether the updation is complete or broken by some other means(Powercut while updating a huge data).

View Replies !
A Date Column That Auto-updates When Any Column In The Row Is Updated
Let's say I have a table with several columns.

I would like to add a column called "date last updated".

How this would work is that any time one of the other columns in that row was updated, the 'date last updated' column would update.

I *know* how to do this with PHP, but here is the special part...

Is there a way to have this automatically just within MySQL, so that EVEN IF if update a column manually through the command line or PHPmyAdmin, the 'date last updated' field updates.

View Replies !
Mammoth Amounts Of Self Joins
I have a table that contains keywords (Varchars) each one mapped to a
product. so the database schema is just an id column, product column and
keyword column.

I want to select the products that contain x,y,z keywords. Now if this query
involves many keywords I end up with a massive amount of self joins on the
keywords table, is there a better way to do this than self joins? What would
work perhaps is multiple unions where I could discard non duplicated rows
but you can't seem to do that. Any ideas... ?

View Replies !
Adding Amounts Of Time
I am looking for a way, as the title suggests, to add a length of time to a time-type field.I needed to type something, and this is what I logically typed (of course, incorrect):

SET playtime=playtime + '$length'

Let's say playtime = 00:10:30, and $length = 00:04:30. What do I need to change the above statement to, so that the new value of playtime = 00:15:00 ?


View Replies !
Import Large Amounts
My client has a large database in MS Access. I need to put a section of this (approximately 900 rows) into MySQL to be displayed on a website.
The thing is, every month I will be resupplied with updated data, which will need to replace the data that is currently in the SQL database.
I am operating on a Mac and they've given it to me as an EXCEL spreadsheet, which I am trying to import into MYSQL using phpMyADmin with no luck.
I've tried exporting from EXCEL to various formats, such as CSV, but I can't seem to get it to import into the MySQL database
Does anyone know what I can do? I need it to be relatively simple so that every month I can simply reimport the new data.
Is there some trick to importing the data from EXCEL, or should I ask the client to supply the data from MS Access in a different format.

View Replies !
Getting The Sum Of Amounts For Each User - How To Join?
I have a simple table for transactions that will store information like a bank account.

To find the balance for a given user I want to sum all the amounts and display the result
How can I do this for more than one user at a time?

CREATE TABLE `transactions` (
`id` int(5) NOT NULL auto_increment,
`user_id` int(10) NOT NULL default Ɔ',
`created` datetime default NULL,
`modified` datetime default NULL,
`description` text character set latin1 collate latin1_general_cs NOT NULL,
`amount` decimal(10,0) NOT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1

I'm hoping to get output like:

user_id | balance(sum of amounts)
------------------------------------------
1 | 70
2 | -70
3 | 10
4 | 5

View Replies !
Handling Large Amounts Of Text
I am desiging a web store to hold and manage up to 150,000 to 200,000 items and have run into a problem which I believe can be fixed but I am not sure about the way to go about it.The problem is that every product has a rich text description that contains a lot of extra HTML code that goes into the database with the product description. I would estimate every product has an average of 10k of description and code.

Now instead of putting all of this into the database would it be possible to write this to a .txt file and keep it in a products_desc folder? Would this keep the database at a respectible size and optmize everything?Does anyone have any good examples or tutorials on going about this with PHP?

View Replies !
Inserting Large Amounts Of Data Into Mysql
I have a whole bunch of numbers and state, county, city, etc. data that i'm trying to load into a database for a demographics website. The data is all in excel currently so I could easily copy and paste it to a text file or another medium if necessary but I'm wondering what the quickest and most efficient way to get it all entered into mysql is.

View Replies !
How To Save Accounts Based On Variable Amounts Of Time
I'm currently building a website where users can signup for various accounts.
An account may last 30 days, 12 months or 24 months.
If a user's account is about to expire, an email notification is send, via a CRON Job.

I want to save the different account types in the database, but I'm not sure how to save the duration of an account. If it was all months, I could simply save ཈' or པ' as an INT, but it also has an account for 30 days, which is more flexible.

Edit:

It would also be nice if I could ORDER BY duration..


View Replies !
Updated Column?
is there a way to obtain only the affected columns after an update query? After an update query, that involves 10 columns, I know that only 2 columns are really updated (because the values of the other cols don't change). I need to know the names of that changed cols, for logging purpose.

View Replies !
Fields Updated
Is there a way to extract what fields were actually updated in an update query?

For example, let's say I have a table with a firstname, a lastname, and a company field, with values of "John," "Smith," and "IBM," respectively. I run this query:

 Update table 
set firstname = "John", 
lastname = "Smith", 
company = "Open Source Development"
where ID = 1 

Is there a mySQL function/query that will tell me that the only field actually updated in this query was the "Company" field, and the other two remained unchanged?

View Replies !
Field Does Not Get Updated
I have an educational course. Every time the student finishes a lesson, I update a field to keep track of where the student has to go when he logs-in next time. Sometimes this works well lesson after lesson. Other times the field simply stops updating even though the student may have gone through many more lessons. It is also unpredictable when the field stops updating.

View Replies !
2 Databases Updated
i have a software running over a mysql db. i want to, for example at midnight myself manually ask it to sinchronize with another db in another host, without the necesity of running the whole mysql again from zero.

View Replies !
Struggling With 'updated'-NOW() Field
I try to learn SQL by figuring out things.
I want to make a listing of all records that were changed in the
last... 1, 6, 12 hours/days.
I have a field called 'updated' managed like: UPDATE tablename SET
updated = NOW(), .... WHERE....
I created a query like this: "SELECT * FROM tablename WHERE 'updated'

View Replies !
Timestamp - To Update When The Row Is Updated.
i would like to have a table with ( among other things ) a time stamp column that holds the time that the row was created.

this seemed easy enough by just executing
ALTER TABLE mytable ADD stampcolumn timestamp;

but the problem with this is that the time stamp updates for a given row any time that row is updated.

I would like to have a timestamp that just stays at its inital value of the row insertion time. is this possible? how?

View Replies !
Importing Updated Data
I've set up a MySQL database and everything is working fine however I've received some updated data (CSV) and need to import it into my database.

The problem is I've added extra fields into the table and whenever I update the data, it goes through ok, but deletes the data from existing that aren't included in the new updated CSV file i'm importing.

View Replies !
Check If A Table Has Been Updated
I'd like to find a way to check if any modifications has been made to a table. I'm using mysql 4.1. I'm trying to find the least resource intensive method of doing this.

View Replies !
Timestamp :: Last Updated Field
I want a timestamp to display when a record has been updated. I create a field in my table in mysql and name it 'last_updated' with the type 'timestamp' and it creates the timestamp in mysql when I view a record. Now how do I get that timestamp to display on the record page on my website with PHP?

View Replies !
Is It Not Possible To Delete The Same Row Which Is Updated Using Trigger?
I am trying to check quantity = 0, if it is equal to zero, I want to delete that row. So basically, on updation of a row, I check for quantity is zero and try to issue delete statement on successful condition. But mysql says, 'Can't update table 'listing' in stored function/trigger because it is already used by statement which invoked this stored function/trigger'

delimiter //
drop trigger catalogue.on_listing_item_zero//

create

trigger catalogue.on_listing_item_zero
after update on catalogue.listing
for each row
begin

if ( NEW.quantity = 0 ) then

delete from
catalogue.listing
where
`sku` = NEW.sku ;

end if;

end;
//

View Replies !
Locking A Record From Being Updated?
I am building a system where more than one person has access to a table, and everyone has the ability to update a record.

How do I prevent a second person being able to update that record if someone else has that record open for editing already?

View Replies !
Checking For Updated Rows??
Is there a query where i can select rows from various tables ordered by when they were last updated/created (whatever comes first) without having a timestamp field in the tables saying when it was created/updated?

View Replies !
Replication Database On Slave Is Not Updated
We are using mysql v4.0.24 on Linux machines.

I'm trying to set up replication with a master and only one slave
database.

The syncronization seems to work well, the relay file on slave is wrote
correctly (Read_Master_Log_Pos and Relay_Log_Pos are updated) but the
information on slave database is not updated.

Master and slave are sincronyzed as shown below but for some reason I
don't understand. I have to say thay sometimes the replication worked but sometimes
setting up a new slave or changing a slave to master it does not. Code:

View Replies !
Decimal Value Gone AWOL In ASP When MySQL Updated!
My ASP driven site has always used MySQL as the DB backbone, mainly as the
hosting costs of MySQL are far cheaper than SQL Server at the mo, and it has
worked fine until my ISP thought that they were doing everybody a favour by
upgrading to v5 from v4.

What happens now is that any ASP query that I do that involves any of my
MySQL Decimal data type fields goes belly up. It will not work.

Looks to be an issue with ASP, MyODBC and MySQL, but I just wanted to check
if there was a better/more reliable data type than Decimal (which obviously
performs the same numerical functions) and if there was a quick way to
convert all of my Decimal fields to this new type.

View Replies !
Last Time A Mysql Database Updated
Here is my problem, my company has been storing fedex data in a access '97 database (the data is imported into this access database via a program called DirectLink), and because we are mainly a php house and we use mySQL, we need to take that information from the access database and mirror it in the mySQL database. To top things off I have to use ASP to write this code to do this.

Now for the Access database I can use a FSO to find out the last time the database was updated. I've had no problem with that. And I've had no problem mirroring the information across to the mySQL database. My problem is, is there a way using the FSO to find out the last time the mySQL database was update. Since mySQL creates several different files for the different databases it holds - is there a specific file I need to look for or is there a query I can run that will tell me?

View Replies !
Sending An Email When A Table Is Updated
I have to create an online bookmakers for a project for college and i want to be able to sent an email confirmation to the winners.I have a bets table containing the fields.

bet , user no. , win

if the win field is true i want the an email to confirm they won.
taking the email address from the users table. which has the fields.

user no. , email address.

View Replies !
Copying Tables Every Time They're Updated
I'm got two tables which need to kept upto date with each other. Is there a command i can cron to copy all the updated entries?

View Replies !
Auto Increment Fields Get Updated
I need to use an auto increment field, but I dont know how they get updated in a query.

If I had say:

INSERT INTO `table` VALUES ( '1','2','3' )

and the 3 row was auto increment, would i put a number, or just put nothing.

View Replies !
Timestamp Not Being Updated - Is My UPDATE Command Right?
PHP

mysql_query("UPDATE prv_msg SET date_read=now() AND confirm=Ƈ' WHERE id='$userid'")or die (mysql_error());

I'm not getting an error message, but a time stamp is not being inserted into the date_read column

View Replies !
Searching Table Which Is Being Constantly Updated Locks Up.
I'm logging mail to a database, and using php to make queries. The mail is
coming in constantly, so the table is being added to, in batches of up to 30
mails. I have around 600k records.

The queries are properly indexed, i think; i have index on date and domain,
the fields I query on.
Mostly the queries run quite fast, but sometimes the queries take up to two
minutes.

The query is a union of two queries into two different tables.

mysqladmin -proc says the query is in state "sending data" for the whole
time.

Should it be a problem querying on a live table this size?
Any parameters I can tweak and/or monitor?

What if I seperated the data in two tables, one for today being updated
constantly, and the other for the historical data, and todays data being
moved to historical at midnight. Then queries to the historical data can be
stored in the query cache.

View Replies !
Show Table Status :: Last Updated Time?
I need to place the date a MySQL table was last updated into a PHP variable.

SHOW TABLE STATUS provides lots of information, including update_time, for all of my tables. But how do I assign the value of update_time for my "members" table into the variable $dateLastUpdated?

View Replies !
Row Cannot Be Located For Updating. Some Values Might Have Changed Since It Was Last Updated
I've recently migrated from access to mysql with vb6). Unfortunately, i get the following error whenever the .update is executed on the recordset.

"Row Cannot be located for updating. Some values might have changed since it was last updated"

The select statement is:
Select * from tablename, connection,3,3 (have also modified the 3,3, to be adOpenDynamic, adLockOptimistic)

I have tried checking the flag To Return Matching Rows, I've added the option = 2 in the connection string, i have a primary key field in the table, and I've also tried re-assigning it to itself.

View Replies !
Field Data Updated Automatically Every Year
I have a membership management system in php that stores members private information in individual mysql database fields. One of them is age. I can have users enter their age and this value is stored in the database field for age. the problem here is that this value is not supposed to remain always the same but it has to increase by one every year obviously. Is there a function in mysql that auto-increments the value of that field automatically every year?

View Replies !
Can I Tell How Many Times A Column Has Been Updated In The Past 2 Weeks?
I have a table with a column that tracks the number of hits an item receives.

Is it possible to find out how many hits an item has received in the past 2 weeks, without altering the structure of the table?

View Replies !
Keeping Specific Fields When Loading Updated Database
I have a production database that dynamically generates web pages. Each time a page is accessed, I increment the number_of_views fields I have created.

And there's a development database that I'm editing.

Every week I upload the development database to the site, delete the old database and load the new database.

Now I'm looking for a way to save the number_of_views fields of the old database when updating. Unfortunately mysqldump allows only for the selection of databases and tables, not for fields.

I could throw away all other fields and dump the remaining number_of_views field with an UPDATE, but there are more than twenty different tables all having this number_of_views field. That's not something I'm willing to do by hand every week.

View Replies !
Updated Table Fields Rolling Back After Update
I'm having to correct some scripts written by a collegue who is presently not around. I had to update 2 fields with over 13000 rows. The update do work well but the problem is that somehow, the initial values in the fields do roll back in again - kind of auto updating to the former values itself. Any ideas what could be wrong? Any way round it?

View Replies !
Date Range :: Month, Year And Date In Separate Columns
I have a database where the date is stored in 3 different collums month, day, year. A am trying to retrieve data by a date range something like "1-1-2005" - "1-1-2007" or something but had quite some difficulty in doing it but I found a way and I am not sure that it is the best way but it appears to work well. Let me know what you think.

"SELECT * FROM database " +
"WHERE datey*365+DAYOFYEAR(CONCAT(datey, '-', datem, '-', dated)) " +
"BETWEEN " + StartDate + " AND " +
"EndDate + " " +
"ORDER BY datey, datem, dated;"

NOTE: StartDate and EndDate use the same formula of (year*365)+dayofyear

View Replies !
Loading Date Format 1-1-2007 To Date Field Doesn't Work
I'm trying to load the date into a date field in mysql so that I can sort by date, but the date field in mysql is yyyy dd mm or yyyy mm dd so it doesn't load. What can I do?

View Replies !
Date :: Select X Number Of Months Ahead Of Current Date
I am trying to query dates stored in my mysql database...
eg:

2005-12-13 (13th Dec 2005)
2006-03-14 (14th Mar 2005)

My SQL query needs to fetch all the records which are X number of months ahead of the current date. eg: I query it saying "get me all records where the date is 1 month from now.... I have used this

(MONTH(date_review)-MONTH(CURDATE()))

which returns 1 - so this is ok - as it's November, and december is one month away.... but when I ask for 3 months - it wont get the records...

I know I somehow need to add the months on - but how do I do this with the year attached too?

View Replies !
Date Format Error :: Not A Valid Date And Time
What's the best format for adding a date to a table? I was using "20040520 10:39:31", but now it's giving me the error: '20040520 10:39:31' is not a valid date and time.

View Replies !
Group By Date, Count Of Multiple Fields Within Date
take table a:

userID INT,
userLogin VARCHAR

and table b:

customerID INT,
userID INT,
customerStarted DATE,
customerFinished DATE

what I'm looking to produce is a report by date, showing number of starts and finishes for all customers marked with a specific userID, like

User 4:
Date | starts | finishes
2008-10-01 | 0 | 5
2008-10-02 | 3 | 3
2008-10-03 | 4 | 2
2008-10-04 | 0 | 0
2008-10-05 | 3 | 3
...
etc.

View Replies !
Output Multiple Records From Start Date To End Date?
Firstly I'm using MySQL 5 on Win2003.

I have a DB table that has multple columns, but the 2 columns I am interested in are DATE_START and DATE_END. So I'll have many records in the DB and the values in these fields will be anything like:

DATE_START=2006-10-23
DATE_END=2006-10-26

Or if its a 1 day thing it will be sumin like:

DATE_START=2006-10-23
DATE_END=2006-10-23

Is there anyway I can output multiple records from the DB for that one record between those dates? For example, the first record above would output:

TITLE | SUMMARY | 2006-10-23
TITLE | SUMMARY | 2006-10-24
TITLE | SUMMARY | 2006-10-25
TITLE | SUMMARY | 2006-10-26

So basically I get a loop of all dates between the start and end date?

Before anyone asks, no I can't loop through this in the code! I have a calendar, and all the dates are created and I just need to populate these dates with the records... and I won't go into detail, but without querying every day, this is the best way by far to do it... just need to know if it can be done?

View Replies !
Passing Date Via Form For Mysql Date Type
I've created a database for tracking our paper inventory. Basically when an individual takes paper, or envelopes the quantity is entered into the database, along with some other items. This all works great.

I also have two fields that use the "Date" and "Time" types for holding the date and time of the initial transaction.

I've created a seperate php script that we will use for our "end of month" reports. The script goes through and adds up the cost of each "purchase" between a specified time frame (1 may thru 31 may for example).

This script works for me as long as I perform my query with my condition formated as such:

View Replies !
DATE COMPARISON :: Get Older Date Between Two Dates
I was wondering if there is a date function to get the older date between two dates?. Or smething that indicates me that one date is older than the other one.I know that I have the function YEAR,MONTH,DAY and I can use them, but I don't know if exists a function that can do the same.

View Replies !
Date/Time Field Update Only Date
I have a field(tmMessage) in a table, it's a date/time struct.
it looks like "2003-09-21 15:52:35"
All I want to do is change the date in this field.
I want the time to stay the same.

View Replies !
Default Date Format And Date Stamping
1.) If possible, change the default date format from YYYY-MM-DD to MM-DD-YYYY.

2.) Auto "date stamp" a newly created record (e.g. I have a field called "date_posted" and would like that field to be auto-filled with the date upon INSERT).

I'm using phpMyAdmin and MySQL version 5.1.30.

View Replies !
Pagination By Date With Multiple Rows For Each Date
I'm not exactly sure what is the best method to use when trying to paginate my results. Currently I have 2 tables:

entries
-------
entryDate
entryText

images
-------
entryDate
imageName

This is the query that I have been using to display all entries and their images on one page:
Code:

SELECT e.entryDate
, e.entryText
, i.imageName
FROM entries AS e
INNER
JOIN images AS i
ON e.entryDate = i.entryDate
ORDER
BY e.entryDate.........................

View Replies !
DATETIME :: Store Date In Date Field
I cant seem to get the correct date to store in my date field...? am i doing something wrong using this insert command:

$sql = "INSERT INTO registration_table (date(NOW()),name,address,...........

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved