mysql视图子查询_mysql创建视图不能包涵子查询的解决办法。View's SELECT contains a subquery in the FROM clause...
如下查詢是沒問題,但要創建成視圖就報View's SELECT contains a subquery in the FROM clause錯誤。
CREATE or REPLACE VIEW `v_user_adunion_reg` AS
select a.name as user_name,b.* from t_users a,t_adunion_result b where a.id = b.userid and orderid is null and czid is null and txid is null and bkid IS null and hbid is null
and b.id in (select id from (select c.userid,min(c.id) as id from t_adunion_result c group by c.userid ) as d);
執行這句會報錯。
解決辦法:通過創建中間視圖作關聯查詢解決。
CREATE or REPLACE VIEW `v_user_adunion_regsub` AS
select c.userid,min(c.id) as id from t_adunion_result c group by c.userid;
CREATE or REPLACE VIEW `v_user_adunion_reg` AS
select a.name as user_name,b.* from t_users a,t_adunion_result b,v_user_adunion_regsub c where a.id = b.userid and b.id =c.id and orderid is null and czid is null and txid is null and bkid IS null and hbid is null ;
總結
以上是生活随笔為你收集整理的mysql视图子查询_mysql创建视图不能包涵子查询的解决办法。View's SELECT contains a subquery in the FROM clause...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c 添加mysql表单的一行数据类型_M
- 下一篇: pythonflat怎么设置_pytho