Jump to content

making a query more simple ?


Person

Recommended Posts

heres the code

 

<?php
$host = "localhost";
$user = "";
$pass = "";
$dbname = "";

$con = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);

$query = "SELECT SUM(1) AS clicks, SUM(`clcpc`), SUM(`chcpc`) FROM `nuke_pnAffiliate_clicktracking` WHERE `pl` = 'rpu' AND  `date` > '20070228'AND `cl` IN (SELECT DISTINCT(cl) FROM rpu_sales WHERE salesman = 'ryan')";

$result = mysql_query($query);
$num_results = mysql_num_rows($result);
    
$row = mysql_fetch_assoc($result);

mysql_free_result($result);

echo $result;

?>

 

It brings up Resource id #5

 

where the myadmin brings up

 

clicks  SUM(`clcpc`)  SUM(`chcpc`)

87343 3423.2699509561 12342.159823611

Does this work OK and is it quicker?

 

SELECT COUNT(a.*) AS clicks, SUM(a.clcpc), SUM(a.chcpc) 
FROM `nuke_pnAffiliate_clicktracking` a
    INNER JOIN rpo_sales s ON a.cl = s.cl
WHERE a.`pl` = 'rpu' 
AND  a.`date` > '20070228'
AND s.salesman = 'ryan'

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.