Hello folks! Does MySQL support calculated fields? Maybe this isn't the right name (I don't really know the database theory), so let me explain by example:
CREATE TABLE pricelist (product VARCHAR(255), price DECIMAL(10,2), price_with_vat = ROUND(price * 1.22, 1)); Now, the column price_with_vat would always contain (obviously) the price including tax. You could use the column name anywhere where you can use normal fields, but of course you could not update it. The column would not (need to) be stored on the disk - that might be optional, for performance tuning. I haven't found a mention of this feature anywhere. Is it on the TODO list? I currently put the expressions directly in the SELECT, but then I can't use them in WHERE. For example: SELECT product, price * 1.22 AS price_with_vat WHERE price_with_vat < 1000; is not legal (price_with_vat is not a known column name in WHERE clause). The only solution that I see is this: SELECT product, price * 1.22 AS price_with_vat WHERE price * 1.22 < 1000; But if I copy the expression again into the WHERE clause, won't it be calculated twice? Also, this is not very elegant in my opinion. Is there a better solution? Thanks. Vaclav Dvorak [EMAIL PROTECTED] IDAS, s.r.o. http://www.idas.cz --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php