wish of those help First off, subqueries in DQL is not possible. See Selecting from subquery in DQL Secondly, you are putting computed SQL from Doctrine Query Language (DQL) into a subquery. This does not work as the database cannot find the column due to DQL prefixing characters/numeric values to the columns.
Can I ORDER my results using a column returned from a subquery within a SELECT clause?
I think the issue was by ths following , Using the example below, which is not the exact code, just an example of what I'm trying to achieve: , Do this:
SELECT temp.* FROM (SELECT
page_instance.name AS 'page name',
WHERE page_instance.id = visitor_event.item_id
) AS 'visit_count'
LEFT JOIN visitor_event_type ON visitor_event_type.id = visitor_event_type_id
LEFT JOIN page_instance ON page_instance.id = visitor_event.item_id
LEFT JOIN page ON page.id = page_instance.page_id
WHERE visitor_event_type.handle = 'viewed'
AND page_instance.name != 'NULL'
GROUP BY page.id
LIMIT 5 ) as temp ORDER BY temp.visit_count DESC
Use result of select column subquery in the where clause of the outer query?
Hope that helps I've got a table User and Company. The User records are a child of the Company records i.e. the User table has a column parent_company_id indicating which company the user is a part of. , There are many ways to do this. But one is to use cross apply:
select c.name, j.james_count
from company c cross apply
(select count(*) as james_count
from [user] u
where first_name = 'James' and u.parent_company_id = company_id
where james_count > 0;
select c.name, count(*) as james_count
from company c join
on u.parent_company_id = c.company_id and u.first_name = 'James'
group by c.name;
SQL where clause to check if all selected column value is in a subquery select
Does that help I'm trying to JOIN a table with a subquery to limit data to only 1 last row, matching certain values from other FROM or JOINed tables: , The solution for me was:
JOIN table2 t2 ON t2.id =
WHERE t1.column2 > table2.column1
ORDER BY table2.date DESC
JOIN table3 t3 ON t2.column1=t3.column2