select *,g=(select case when grade in (3,5,8) then 0 else 1 end from grade where [user]=a.[user]) from content a order by g
解决方案 »
- 在表单提交时需要做一次数据查询操作
- php解析xml到mysql
- 图片上传到异地服务器的问题
- 为什么数据老插入不到数据库 ? 菜鸟求解
- 【急】如何实现 php 服务器端 1个对象(单例模式)的问题!
- function b($name, &$value) 里面 $value 前面的& 是干啥的啊?
- globals的作用
- PHP2.3之后,post类要用$HTTP_POST_VARS取得,get 类的要用$_REQUEST取得,如何配置才可以不用$_REQUEST也可取得?
- 请教
- 在php中有没有像asp中的application("aa")这样的变量,可以在整个网站上保存变量,没有时间限制.
- 如何使程序每查询到一条结果即显示在网页上?
- PHP ADODB连接oracle 主机字符串的问题
我套用你的语句,会出现找不到g字段,还有“from content a order by g”
这里的a是什么意思?
select id,title_c,picture1,alterdate,detailed_c,abc=(select case when grade in (3,5,8) then 0 else 1 end from grade_c where grade_c.userid=gongqiu.userid) from gongqiu where infotype=1 and statecode=1 order by abc asc,alterdate desc会提示字段abc不存在,汗,能力有限。
from
(select
[id] c1,
title_c c2,
picture1 c3,
alterdate c4,
detailed_c c5,
c6=(select case when grade in (3,5,8) then 0 else 1 end from grade_c where userid=A.userid)
from gongqiu A
where infotype=1 and statecode=1) B
order by B.c6 asc,B.c4 desc
是啊,两表userid关联,表grade中的grade值为3、5、8时,表content的记录排序靠前,zl_c 思路是对的,可是我掌握不了。
改为:
SQL codeselect *,(select case when grade in (3,5,8) then 0 else 1 end from grade where [user]=a.[user]) as g from content a order by g改为:
SQL codeselect id,title_c,picture1,alterdate,detailed_c,(select case when grade in (3,5,8) then 0 else 1 end from grade_c where grade_c.userid=gongqiu.userid) as abc from gongqiu where infotype=1 and statecode=1 order by abc asc,alterdate desc
即,用“as”替换“=”赋值。