数据库查询语句写法继续求助【有图】
时间:2011-08-06
来源:互联网
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open(this.src);}" onmousewheel="return imgzoom(this);" alt="" />
图示为数据表pw_forums的信息,目前需要补充语句段A和语句段B,代码如何写呢?
详见代码中的疑惑,求助论坛高人解决。
-----------------------------------
$fltshow = ''; //定义$fltshow变量为空
语句段A…… //如何在表pw_forums中查询符合pf.dirname = 'bbs2'条件的分类版块的fid数组,图中即为7和8。
语句段B…… //如何在表pw_forums中通过刚获得的分类版块pf.fid数组(对应普通版块的pf.fup),进一步查出相应的普通版块fid数组(图中即为9、11、18、13、14)并赋给变量$justshow
if(!empty($justshow)) //如果$justshow变量非空
$fltshow = "AND pt.fid IN ($justshow)"; //插入到首页排行榜调用语句where某条件后
-----------------------------------
-----------------------------------
$fltshow = '';
$justshow=$db->query("SELECT fid FROM pw_forums M WHERE EXISTS(SELECT 1 FROM pw_forums N WHERE N.dirname='bbs2' AND N.fid=M.fup)");
if(!empty($justshow)){
$fltshow = "AND pt.fid IN ($justshow)";
}
在大侠jinguanding的指导下,采用上述代码在测试过程中提示错误如图。
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open(this.src);}" onmousewheel="return imgzoom(this);" alt="" />screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open(this.src);}" onmousewheel="return imgzoom(this);" alt="" />
发现变量$justshow值为Resource id #23,而变量$fltshow则对应为AND pt.fid IN (Resource id #23)
实际上,最终希望实现的是$fltshow = "AND pt.fid IN (9,11,18,13,14)";
该如何修改完善呢?
[ 本帖最后由 sjkstudy 于 2011-8-6 13:30 编辑 ]
图示为数据表pw_forums的信息,目前需要补充语句段A和语句段B,代码如何写呢?
详见代码中的疑惑,求助论坛高人解决。
-----------------------------------
$fltshow = ''; //定义$fltshow变量为空
语句段A…… //如何在表pw_forums中查询符合pf.dirname = 'bbs2'条件的分类版块的fid数组,图中即为7和8。
语句段B…… //如何在表pw_forums中通过刚获得的分类版块pf.fid数组(对应普通版块的pf.fup),进一步查出相应的普通版块fid数组(图中即为9、11、18、13、14)并赋给变量$justshow
if(!empty($justshow)) //如果$justshow变量非空
$fltshow = "AND pt.fid IN ($justshow)"; //插入到首页排行榜调用语句where某条件后
-----------------------------------
-----------------------------------
$fltshow = '';
$justshow=$db->query("SELECT fid FROM pw_forums M WHERE EXISTS(SELECT 1 FROM pw_forums N WHERE N.dirname='bbs2' AND N.fid=M.fup)");
if(!empty($justshow)){
$fltshow = "AND pt.fid IN ($justshow)";
}
在大侠jinguanding的指导下,采用上述代码在测试过程中提示错误如图。
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open(this.src);}" onmousewheel="return imgzoom(this);" alt="" />screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open(this.src);}" onmousewheel="return imgzoom(this);" alt="" />
发现变量$justshow值为Resource id #23,而变量$fltshow则对应为AND pt.fid IN (Resource id #23)
实际上,最终希望实现的是$fltshow = "AND pt.fid IN (9,11,18,13,14)";
该如何修改完善呢?
[ 本帖最后由 sjkstudy 于 2011-8-6 13:30 编辑 ]
作者: sjkstudy 发布时间: 2011-08-06
好乱啊 ..
作者: zty5984 发布时间: 2011-08-06
SELECT fid FROM pw_forums M WHERE EXISTS(SELECT 1 FROM pw_forums N WHERE N.dirname='bbs2' AND N.fid=M.fup)
这句是否不适用?
版块fid 为9,11,18,13,14这多行对应的dirname是空的噢。
这句是否不适用?
版块fid 为9,11,18,13,14这多行对应的dirname是空的噢。
作者: sjkstudy 发布时间: 2011-08-06
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28