Field operation in sql query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mariolopes
Forum Contributor
Posts: 102
Joined: Sun May 22, 2005 7:08 am

Field operation in sql query

Post by mariolopes »

Hi
I have in my table two fields one named preco_custo and other named preco_venda. Is possible in my sql evaluate the difference between this 2 fields. I need a sal like
$query ="select nome, venda, preco_custo-preco_venda from negocios"
Any ideas?
Thank you
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Field operation in sql query

Post by s.dot »

Yes.

$query ="select nome, venda, preco_custo-preco_venda AS `diff` from negocios"
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
mariolopes
Forum Contributor
Posts: 102
Joined: Sun May 22, 2005 7:08 am

Re: Field operation in sql query

Post by mariolopes »

Thank you
That's what I need
Post Reply