LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-01-2007, 07:58 AM   #1
grabro
Member
 
Registered: Oct 2003
Location: Chester
Distribution: Mepis 6.0
Posts: 125

Rep: Reputation: 15
Msql - Updating calculated fields


Hi

I have a database in mysql with a series of linked tables one of which as the following columns

Id; Datejoined; D.O.B; duration; Age. The last two columns are calculated based upon the first two respectively.

I would like to know if it is possible to update these calculated columns automatically everytime I view the table. At the moment I have to recalculate each row individually to keep these upto date.

I hope somebody can help either through SQL or a script.


Grabro
 
Old 08-01-2007, 08:15 AM   #2
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Rep: Reputation: 30
Sounds like you have two distinct issues here.

1. Updating the records.
2. Displaying the records.

Are you looking to update all the records automatically, or just update the particular ones when you want to view them?

Centinul

::EDIT:: Additionally how do you define age? Do you want it in just years or years, days, months, minutes, seconds?

Last edited by Centinul; 08-01-2007 at 08:17 AM.
 
Old 08-01-2007, 08:37 AM   #3
grabro
Member
 
Registered: Oct 2003
Location: Chester
Distribution: Mepis 6.0
Posts: 125

Original Poster
Rep: Reputation: 15
Mysql - Updating Calculated Fields

Centinul

Displaying the record is not a problem except that when they are displayed the duration and age columns will still show the years when that particular record was entered or specifcally updated.

I can update each record individually to amend these columns but I would rather not as there is a lot of them.

These columns only have the number of years in them so soem would changing and some wouldn't.

I am not aware that the usual UPdate function will work on a calculeted field or will only work
by adding a specific thing e.g. Age +1 to increase age by one.

Grabro
 
Old 08-01-2007, 11:25 AM   #4
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Rep: Reputation: 30
So are you looking for a way to batch update the records or a way to update the records dynamically when a user views them?

Thanks,

Centinul
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Amarok won't use Msql coralsaw Debian 1 08-22-2006 04:46 AM
Where to find my msql db r0ck Slackware 8 12-23-2004 04:39 PM
msql and hostname problems krayz1e Linux - Newbie 4 09-04-2004 01:48 AM
msql bm1 Slackware 2 02-05-2004 12:18 AM
msql++ c++ api for mysql nakkaya Linux - Software 0 04-19-2003 03:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration