...

View Full Version : Query Formating



Atrhick
12-19-2011, 04:47 PM
Hey guys a quick question here... I wanted to know if the query below is correct in terms of its syntax I have not tested the query yet. I have a lot of thing to change to look like this and I wanted to make sure i was on point first.



$strQuery3 = "SELECT SUM($myStr3) AS totalPings "
. " FROM auto_pings "
. " WHERE $myStr3 = 1 AND date BETWEEN '$form' AND '$to' ";

Old Pedant
12-19-2011, 11:24 PM
Um...$form? I suspect you mean $from.

Yes, that should work. But you would get the same results from doing


$strQuery3 = "SELECT COUNT(*) AS totalPings "
. " FROM auto_pings "
. " WHERE $myStr3 = 1 AND `date` BETWEEN '$from' AND '$to' ";

since the SUM of a bunch of 1's is obviously going to be the same as the count of that same bunch.

Note that I enclosed date in `...`. It's not strictly required, but it's a good idea, since date is a builtin function in MySQL.

Atrhick
12-20-2011, 04:35 PM
Um...$form? I suspect you mean $from.

Yes, that should work. But you would get the same results from doing


$strQuery3 = "SELECT COUNT(*) AS totalPings "
. " FROM auto_pings "
. " WHERE $myStr3 = 1 AND `date` BETWEEN '$from' AND '$to' ";

since the SUM of a bunch of 1's is obviously going to be the same as the count of that same bunch.

Note that I enclosed date in `...`. It's not strictly required, but it's a good idea, since date is a builtin function in MySQL.


Awesome thank you so much!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum