union 两表联表查询 查找三个参数不行

浏览:1444 发布日期:2016/11/04 分类:ThinkPHP5专区 关键字: union 三个参数
为什么下面查找两个表中的两个参数就ok:$cha="php";
$re = Db::field('id name')->table('jd_article')->union("SELECT  id name FROM jd_new where name like '%" . $cha . "%'")->where("name like '%" . $cha . "%'")->paginate(3);
print_r($re);
而三个参数以上呢?却不行$cha="php";
$re = Db::field('id name logo')->table('jd_article')->union("SELECT  id name logo FROM jd_new where name like '%" . $cha . "%'")->where("name like '%" . $cha . "%'")->paginate(3);
print_r($re);
报错:[code]SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'logo FROM jd_new where name like '%php%'' at line 1[code]郁闷...求解!
最佳答案
评论( 相关
后面还有条评论,点击查看>>