PDA

View Full Version : 2 queeries of the same to one.


SmEdD
05-28-2003, 08:06 PM
How can I make this into one querie. I belive you can just not smart enought. Still a n00b.

$getpoststoday=$DB_site->query_first("SELECT count(*) AS count FROM post WHERE dateline>='$vbs_today'");
$poststoday=number_format($getpoststoday[count]);
$getthreadstoday=$DB_site->query_first("SELECT count(*) AS count FROM thread WHERE dateline>='$vbs_today'");
$threadstoday=number_format($getthreadstoday[count]);

SmEdD
05-28-2003, 08:07 PM
NVM I'm a idiot you can't because there diffrewnt tables.

filburt1
05-28-2003, 08:08 PM
Why not? Look up JOINs and other tricks.

Xenon
05-28-2003, 08:21 PM
on table is enough for that:

$getpoststoday = $DB_site->query_first("SELECT count(postid) AS posts, COUNT(DISTINCT(threadid)) AS threads FROM post WHERE dateline>='$vbs_today'");
$poststoday = number_format($getpoststoday['posts']);
$threadstoday = number_format($getthreadstoday['threads']);

Boofo
05-28-2003, 08:49 PM
How would you add today's thread views in there?

Xenon
05-28-2003, 08:51 PM
Bob, it's impossible, because threadviews are not saved with datelines, so you can just get the ammount of views those threads have in total

Boofo
05-28-2003, 09:14 PM
Shows you what I know about queries, huh? ;)