$sql_notice = "select * from $t_article art inner join $t_article_cat cat where art.cat_id=cat.cat_id and cat.cat_id='$ncat_id' and cat.is_show=1 and art.is_show=1 order by art.short_order desc limit 0,10";
这句代码哪里错了,为什么降序实现不了?
$sql_cat = "select * from $t_article_cat where is_show=1 and shop_id='$shop_id' order by sort_order asc limit 0,1";
$cat_notice = $dbo->getRs($sql_cat);
foreach($cat_notice as $value){
$ncat_id=$value['cat_id'];
$sql_notice = "select * from $t_article art inner join $t_article_cat cat where art.cat_id=cat.cat_id and cat.cat_id='$ncat_id' and cat.is_show=1 and art.is_show=1 order by art.short_order desc limit 0,10";
$notice = $dbo->getRs($sql_notice);
人气:327 ℃ 时间:2020-09-10 08:39:26
解答
你没有设置连接关系 on art.cat_id=cat.cat_id ,修改如下
$sql_notice = "select art.* ,cat.* from ".$t_article." art inner join ".$t_article_cat." cat on art.cat_id=cat.cat_id where cat.cat_id='".$ncat_id."' and cat.is_show=1 and art.is_show=1 order by art.short_order desc limit 0,10";
echo $sql_notice;还是没有变。。你把echo$sql_notice 的 sql在 查询分析器中 执行 看看 就知道了, 语句中 是 按照short_order 字段的降序排列的
推荐
猜你喜欢
- 四字成语填空()()有序
- 甲、乙两人各有钱若干元,甲拿出1/6给乙后,乙又拿出1/5给甲,这时他们各240元,两人原来各有多少元?
- 10prs/20bags/10boxes/ctn是什么意思?
- “The+单数名词”特指一类事物吗?那么如果我要表达:特指“那一个”呢?
- 为了测量某种液体的比热容,把质量为100g的铜块从沸腾的水中取出(标准大气压),迅速投入质量为100g、温度为10摄氏度的待测液体中,混合后的共同温度是25摄氏度,若不计热量损失,求这种液体的比热容为多少?
- 如图,在正方形ABCD中,对角线2倍根号2,则正方形的边长为?
- 函数y=根号下sinx+根号下tanx的定义域
- 一个三角形和一个平行四边形等底等高,这个平行四边形的面积比三角形的面积大2.6㎡,这个平行四边形的面积是( )㎡.