S
S
savchenko912018-04-20 15:08:17
symfony
savchenko91, 2018-04-20 15:08:17

How to style queryBuilder?

I am new to sql, and even more so to queryBilders, and how much documentation I have not read, I could not figure out how to issue such a simple sql query:
SELECT image_id FROM item_image WHERE item_id =
(
SELECT GROUP_CONCAT(item_id) FROM item WHERE catalog_id =
(
SELECT GROUP_CONCAT(catalog_id) FROM catalog WHERE category_id=9
)
)
in short, first 1) I will collect all id catalogs that have category 9, 2) then I will collect all the items that are in these catalogs, 3) then I will get all the pictures that these items have, i.e. I need to get the result several times and make a request based on it. But huh?
because I want to arrange everything in one column, so that it is beautiful, something like this:
$query->select(smth)
->from('smth', 'ap')
->innerJoin('ap', 'smth', 'p', 'ap.smth = p.smth')
->leftJoin( 'ap', 'smth', 'cadt', 'cadt.smth = p.smth')
->groupBy('ap.smth')
->orderBy('ap.smth, 'DESC')
->limit($ count)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-04-20
@Minifets

It will not work in a column, for each subquery you will need to initialize a separate QueryBuilder, as here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question