2 czz kb czz_kb 于 2015.06.12 15:05 提问

thinkphp中union使用问题

代码
$result4=$activity->where("topic='%s' and city='%s'","top",I('get.city'))->field('createTime,title,readCount,id,belong')->table('gq_activity')->union('SELECT createTime,title,readCount,id,belong FROM gq_preferential WHERE topic="top"')->union('SELECT createTime,title,readCount,id,belong FROM gq_multimedia WHERE topic="top"')->union('SELECT createTime,title,readCount,id,belong FROM gq_travel WHERE topic="top"')->select();
主要问题
怎么样在union('SELECT createTime,title,readCount,id,belong FROM gq_preferential WHERE topic="top"')里在where里使用变量用于筛选出数据。因为如果用union('SELECT createTime,title,readCount,id,belong FROM gq_preferential WHERE topic="top" and id="$id"),会报错。

1个回答

u010189941
u010189941   2015.06.15 23:50

贴重点,直接贴全部代码没人看…

u010189941
u010189941 有点晕。。
2 年多之前 回复
czz_kb
czz_kb 恩恩,谢谢
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片