jeffwalden — 2010-03-07T20:33:38-05:00 — #1
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.
rustybuddy — 2010-03-09T15:26:55-05:00 — #2
That's a funny clip!!!
r937 — 2010-03-07T20:41:18-05:00 — #3
yes you can
the syntax is pretty much exactly what you have shown
test it, and see
jeffwalden — 2010-03-07T20:47:00-05:00 — #4
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.
r937 — 2010-03-07T21:00:26-05:00 — #5
we ain't got no quotes... we don't need no quotes... i don't have to show you any stinkin' quotes!!
jeffwalden — 2010-03-07T21:11:24-05:00 — #6
Rudy, where did this come from?! :rofl:
I think I managed to get it working. It's amazing what happens when I spell the table name correctly!
r937 — 2010-03-07T21:32:27-05:00 — #7
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...
jeffwalden — 2010-03-07T21:35:11-05:00 — #8
Guess that was a smidge before my time.
... still funny.