从子查询选择中选择字段

编程入门 行业动态 更新时间:2024-10-11 19:22:59
本文介绍了从子查询选择中选择字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有这个查询,只是从ad_media获取字段,但是我不知道如何选择子查询选择中的字段以及从左到ad_params any的字段确实可以帮助您

I have this query that getting the fields just from ad_media , but i can't figure out how to select also the fields that are in the subquery selection as well as the fields from the left join with ad_params any help thanks indeed

select ad_media.ad_media_id , ad_media.ad_id from ad_media where ad_media.ad_id in ( select action_states.ad_id from action_states where action_states.state = 'reg' and action_states.action_id = '1' and action_states.timestamp::date between '2018-04-17' and '2018-04-17' and action_states.ad_id in ( select ads.ad_id from ads where ads.category = '2010' and ads.name = 'joe' ) ) left join ad_params on ad_media.ad_id = ad_params.ad_id;

推荐答案

您可以尝试内部加入而不是子查询:

SELECT ad_media.ad_media_id, ad_media.ad_id FROM ad_media INNER JOIN action_states ON action_states.ad_id = ad_media.ad_id INNER JOIN ads ON ads.ad_id = action_states.ad_id LEFT JOIN ad_params ON ad_media.ad_id = ad_params.ad_id WHERE action_states.state = 'reg' AND action_states.action_id = '1' AND action_states.timestamp::DATE BETWEEN '2018-04-17' AND '2018-04-17' AND ads.category = '2010' AND ads.name = 'joe';

更多推荐

从子查询选择中选择字段

本文发布于:2023-11-22 02:20:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1615593.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段   从子

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!