select count(people) c from people where people='乐乐'
上面这条sql就是原理
php利用代码
<?php $p=$_POST['p']; $cnx = new PDO("odbc:Driver={SQL Server};Server=;Database=;",'',''); $ps=$cnx->query("select count(people) c from people where people='".$p."'"); foreach($ps as $s){ if ($s['c']=='0'){ echo "用户可用"; }else{ echo "此用户名已存在"; } } ?>