Results 1 to 8 of 8
Mar 7, 2010, 18:33 #1
- Join Date
- Sep 2002
- Los Angeles
- 5 Post(s)
- 0 Thread(s)
Math in the Query - Can I Do This?
Let me start off by saying that my SQL queries have been pretty simple since I started coding. When I say simple, I mean that I just select a bunch of information from static inputs. Now, I've come across a situation where I need to do a calculation within the query itself. Something like this:
SELECT * FROM Table WHERE Table.Rent <= ($Amount * Table.Rooms)
Rent is a column of the table and is a numeric value.
$Amount is an input provided by the user and is a numeric value.
Rooms is a column of the table and is an integer.
I guess I could first query the number of Rooms and do the math with some PHP code before I run a second query but that just seems like a lot of work. Anyway, if I can do math, what's the syntax? Just need an example and I can go form there.TAKE A WALK OUTSIDE YOUR MIND.