1.SELECT Count (*) from ' feed ' WHERE ' uid ' =1121293
You can return the total number of eligible records
The following method is recommended by me.
SQL statement: Select 1 from tablename where col = col Limit 1;
The number of rows affected by the execution of the statement is then read.
Of course it's important to limit 1 here. This will not be looked down after MySQL finds a record. The number of rows affected by this implementation is either 0 or 1, and performance has improved considerably.
If you're using a PDO, you can use ROWCOUNT () and it's easy to get to the number of rows affected by the execution.
2.SELECT * from ' feed ' WHERE ' uid ' =1121293 limit 1
Can return the field contents of a record
3.SELECT EXISTS (SELECT * from ' feed ' WHERE ' uid ' =1121293)
You can only determine whether a record exists, and the SELECT * in a subquery is ignored when it is executed.
4. Use the procedure to judge
<?php
$sql = "SELECT * from checklist where game_id= $gid and task= ' $task ' and status= ' $status '";
$result =mysql_query ($sql);
$row = Mysql_fetch_array ($result, MYSQL_ASSOC);
if (!mysql_num_rows ($result))
{
echo "Record doesn ' t exist~~~~~!!!!!!";
}
Else
{
echo mysql_num_rows ($result);
echo $row [' game_id '];
echo $row [' Task '];
}
?>
The above three methods generally think the third is the most efficient.