alias用于设置当前数据表的别名,便于使用其他的连贯操作例如join方法等。 示例: $Model = M('User'); $Model->alias('a')->join('__DEPT__ b ON b.user_id= a.id')->select(); 最终生成的SQL语句类似于: SELECT * FROM think_user a INNER JOIN think_dept b ON b.user_id= a.idhttp://document.thinkphp.cn/manual_3_2.html#alias
那类似于这种原生的sql select count(*) from (select * from user where userId >10) as a; 把一个查询结果集起别名为a ,再count计数a 这样的操作thinkPHP应该怎么写?
示例:
$Model = M('User');
$Model->alias('a')->join('__DEPT__ b ON b.user_id= a.id')->select();
最终生成的SQL语句类似于:
SELECT * FROM think_user a INNER JOIN think_dept b ON b.user_id= a.idhttp://document.thinkphp.cn/manual_3_2.html#alias
select count(*) from (select * from user where userId >10) as a; 把一个查询结果集起别名为a ,再count计数a
这样的操作thinkPHP应该怎么写?