0

first method

$sql_m = mysql_query("select count(t_id) as ad from t_master where product_id='$pro_id' AND order_id='$or_id'");
$st_id_m = mysql_fetch_assoc($sql_m);
$st_id_m = $st_id_m['ad'];

second method

$sql_m = mysql_query("select * from t_master where product_id='$pro_id' AND order_id='$or_id'");
$st_id_m = mysql_num_rows($sql_m);

which is the best method for given better performance in large database and get number of record.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
Prakash Tank
  • 41
  • 1
  • 8
  • 1
    Neither.... they both use the old, deprecated mysql extension, and should be using mysqli or pdo; and then they can also use bind variables, so you don't need to worry about SQL injection via `$pro_id` and `$order_id` – Mark Baker Jan 18 '17 at 10:23
  • Select COUNT() will be faster than mysql_num_rows(), internally the server will process the request differently. – Ashly Jan 18 '17 at 10:32
  • Thank you for your answer... Mark Baker & AShly – Prakash Tank Jan 18 '17 at 10:50

0 Answers0