astaroth Posted April 30, 2003 Share Posted April 30, 2003 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?? :?: Quote Link to comment https://forums.phpfreaks.com/topic/416-mysql-count-query-from-different-tables/ Share on other sites More sharing options...
shivabharat Posted April 30, 2003 Share Posted April 30, 2003 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); Quote Link to comment https://forums.phpfreaks.com/topic/416-mysql-count-query-from-different-tables/#findComment-1394 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.