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.
Pretty much? I’ll throw some quotes in there and see. Guess my initial testing bombed out so I wasn’t sure if something like this was even possible. Now that I know there’s a light at the end of the tunnel I’ll get to work.