mysql computed field


I'm not sure if i can do this, but is it possible to make a computed field in mysql, like say for instance I want to have a field called fullname which will automaticaly create a users full name from the field firstname and lastname. Also, if this is possible is it possible to have computed fields between tables, like say for instance i have a table for a customers quotes, with a dollar amount, and then i have another table called customerTotals which gives the customers total dollar amount of quotes for the year, is it possible to have this total dollar amount of quotes for the year field calculated even tho they are in different tables?


- Loren
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

i dont think this is possible... mysql is just storage, i dont think it has these features

if im wrong, someone plz correct me... this sounds rather interesting if it does exist
for the first question, yes :

SELECT CONCAT_WS(' ', firstname, lastname) AS fullname
FROM customers

for the second question probably yes but i don't have your table structure. it should be something like this :

SELECT CONCAT_WS(' ', c.firstname, c.lastname) AS fullname, ct.amout, SUM(cq.quotes) AS yearquotes
FROM customers AS c INNER JOIN customertotal AS ct ON c.customerid = ct.customerid
                                 INNER JOIN customerquotes AS cq ON (c.customerid = cq.customerid AND ct.year = cq.year)
GROUP BY cq.customerid, cq.year

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LTY83Author Commented:
but can this be done in the table automatically, IE: data is entered thru asp/sql but in the table the full name field generates itself?
yes, you can update a field with a computed expression :

UPDATE customer SET fullname = CONCAT_WS(' ', firstname, lastname)
WHERE fullname IS NULL
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.