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.
yes you can
the syntax is pretty much exactly what you have shown
test it, and see
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.
we ain’t got no quotes… we don’t need no quotes… i don’t have to show you any stinkin’ quotes!!
Rudy, where did this come from?!
I think I managed to get it working. It’s amazing what happens when I spell the table name correctly!
treasure of the sierra madres with humphrey bogart
if this launches for you in windows media player, it should loop, and it gets pretty funny after it has repeated about a dozen times…
Guess that was a smidge before my time.
… still funny.