4 回答

TA貢獻(xiàn)18條經(jīng)驗 獲得超1個贊
select * from where xx=‘xx’ and ?xx=‘xx’limit(開始位置,個數(shù));
or 是 或者 多敲兩遍你就會了
select * from where xx=‘xx’ or xx=‘xx’;(xx為同一字段,‘xx’為不同的值)

TA貢獻(xiàn)9條經(jīng)驗 獲得超4個贊
select?u.username,u.photo,c.uid,sum(points)?as?points,p.cpost,m.comment?from?credit?as?c?left?join? user?as?u?on?u.id=c.uid?and?p.category?=5?left?join?(select?uid,count(uid)?as?cpost?from?post? group?by?uid)?as?p?on?p.uid=c.uid?left?join(select?user_id,count(user_id)?as?comment?from?comment group?by?user_id)?as?m?on?m.user_id=c.uid?group?by?c.uid?order?by?points?DESC?limit?100;
今天剛碰到的,
and 和 or 表示條件;and是求交集,or求并集;
limit放在最后限制條數(shù);
具體搜索吧;

TA貢獻(xiàn)1條經(jīng)驗 獲得超0個贊
<?php
$dqtime=date('y-m-d H:i:s',time());
$con = mysql_connect(數(shù)據(jù)庫地址,賬號,密碼);
if (!$con)//判斷是否正常連接數(shù)據(jù)庫
?{
die('Could not connect: ' . mysql_error());
?}
mysql_select_db(庫名, $con);//選擇庫名
mysql_query("set names utf8" );//設(shè)置數(shù)據(jù)庫編碼
$zNum=mysql_num_rows(mysql_query("SELECT * FROM 字段名"));//判斷數(shù)據(jù)庫有多少數(shù)據(jù)
$right=mysql_num_rows(mysql_query("SELECT * FROM 字段名 where id=118 and money >100")); //選擇ID=118 且 錢大于100的數(shù)據(jù)信息
$pass=mysql_num_rows(mysql_query("SELECT * FROM 字段名 where `當(dāng)前狀態(tài)`='密碼錯誤' or id<100 order by id desc limit 5,20"));要么ID小于100 要么 密碼錯誤的 數(shù)據(jù)信息 按照 ID 升序 排列 選擇 第5 到20個
?>
添加回答
舉報