On Tue, 27 May 2003 12:18:13 -0400, David Shelley wrote:

> I'm new to mySQL, but like what I see so far.
> I'm converting several databases from other products to mySQL 4.0.12 for
> improved speed and reliability. But I'm having trouble with computed
> columns. I don't see how to define them. Can't find it in the manual.pdf.

You don't see how to define them because I don't think that MySQL (or 
any SQL engine) has them. Plus, I would bet that using calculated 
columns violates some type of data normalization, and would also 
probably slow down MySQL considerably.

It sounds like you are trying to convert some FileMaker data tables. 
Off the top of my head it's the only system that lets (actually forces) 
you to do calculated values in the data table. (It's my biggest pet 
complaint about FMP along with repeating values.)

> I need 2 computed columns, 1st takes the columns fName and lName and appends
> them together with a space between. 2nd column, numDays, takes sDat
> (contract start date) and eDat (end date) and calculates eDat-sDat+1.
> 
> Can someone please help me figure out how to define these columns.

You can do what you want on retrieval (or for that matter on INSERTion) 
with:

SELECT CONCAT(fName, ' ', lName) as FullName,
        (TO_DAYS(eDat) - TO_DAYS(sDat) + 1) as DaysDuration
        FROM mytable;

But, then you probably already knew that. <grin>

---
Listserv only address.
Jeff Shapiro

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to