Reputation:
$sql = "SELECT count(u_id) AS num_replies FROM `replies` WHERE `u_id`='".$uid."'";
$res = mysql_query($sql) or die(myqsl_error());
Will that return the number of replies a user with id $uid has made? If not, can anyone suggest something that will?
Thx for the help.
Upvotes: 0
Views: 149
Reputation: 3917
$ssql = "SELECT count(*) AS num_replies FROM replies WHERE u_id = $uid";
$rres = mysql_query($ssql);
Upvotes: 0
Reputation: 50602
Please, for the love of the internet, don't built an SQL query yourself. Use PDO.
Upvotes: 1
Reputation: 37645
It will return the number of records in the table with that u_id. Doesn't matter what you put in the paretheses. You don't need any GROUP BY clause.
Upvotes: 0
Reputation: 1448
It difficult to answer this question without knowing more about the replies table, but just looking at your query, then yes your query looks like it will.
Upvotes: 5