Jump to content

Archived

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

astaroth

MySql count query from different tables

Recommended Posts

I have problem.... i need a count of how many firms name are searched in the table of Requests, The firm ID is in the table Com...

 

 


$name=("SELECT SUBSTRING(Name,1,4) FROM Com WHERE Com.ComID=\'$CID\'"); 

$query=("SELECT count(*) as CD FROM Com LEFT JOIN Requests ON 

Com.ComID=Requests.ID WHERE  Action=\'search\' && Keyword like 

\'%$name%\'");



   $result=mysql_query("$query");

   while($r = mysql_fetch_array($result)) {

        $r[CD];

}





The problem is that SQL dont accepts $name in Keyword like \'%$name%\'\");

May be someone can help.....any ideas?? :?:

Share this post


Link to post
Share on other sites

How about using

 

mysql_num_rows

 

$query=("SELECT count(*) as CD FROM Com LEFT JOIN Requests ON 

Com.ComID=Requests.ID WHERE  Action=\'search\' && Keyword like 

\'%$name%\'"); 

$result = mysql_query($query,$db);

$numrows = mysql_num_rows($result);

Share this post


Link to post
Share on other sites

×

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.