MySQL Select and json format products from multiple sources

Learning SQL in the middle of an internship i’m doing and just wrote my first (at least what I would call) complex query. The query has to return information from a relational DB about all product catalogs from a company and the products that they contain in a json format, which can reference products through a simple many to many relationship of
[catalogs] <-> [products] AND/OR through [catalogs] <-> [product groups] <-> [products]
I’m new to SQL and using MySQL 5.7.14. I don’t know if this is particularly optimized or at all good practice so those are my biggest concerns with my query.
There might also be some redundant joins because I’m not entirely comfortable with the scoping of subqueries.

Anyway… Here goes nothin’

SELECT
    cat.*,
    CONCAT('[',
        GROUP_CONCAT(CONCAT(
            '{"id":',                        p.id,
            ', "name":"',                IFNULL(p.name, ''),
            '", "image_url":"',        IFNULL(p.image_url, ''),
            '", "description":"',    IFNULL(p.description, ''),
            '"}')
        ORDER BY p.id),
    ']') AS products,
    CONCAT('[',
        GROUP_CONCAT(DISTINCT CONCAT(
            '{"id":',                        pg.id,
            ', "name":"',                IFNULL(pg.name, ''),
            '", "products": ',        IFNULL(pg.product_group_product_list, ''),
            '}')
        ORDER BY pg.id),
    ']') AS product_groups
FROM
    companies AS c
        LEFT JOIN
    catalogs AS cat ON cat.company_id = c.id
        LEFT JOIN
    catalog_products AS cpjoin ON cpjoin.catalog_id = cat.id
        LEFT JOIN
    products AS p ON p.id = cpjoin.product_id
        LEFT JOIN
    catalog_product_groups AS cpgjoin ON cpgjoin.catalog_id = cat.id
        LEFT JOIN (
            SELECT
                pg2.*,
                CONCAT('[',
                    GROUP_CONCAT(DISTINCT CONCAT(
                        '{"id":',                        p.id,
                        ', "name":"',                IFNULL(p.name, ''),
                        '", "image_url":"',        IFNULL(p.image_url, ''),
                        '", "description":"',    IFNULL(p.description, ''),
                        '"}')
                    ORDER BY p.id),
                ']') AS product_group_product_list
            FROM
                companies AS c2
                    LEFT JOIN
                catalogs AS cat2 ON cat2.company_id = c2.id
                    LEFT JOIN
                catalog_product_groups AS cpgjoin2 ON cpgjoin2.catalog_id = cat2.id
                    LEFT JOIN
                product_groups AS pg2 ON pg2.id = cpgjoin2.product_group_id
                    LEFT JOIN
                product_group_products AS pgjoin2 ON pgjoin2.product_group_id = pg2.id
                    LEFT JOIN
                products p ON p.id = pgjoin2.product_id
            GROUP BY
                pg2.id
            ) AS pg ON pg.id = cpgjoin.product_group_id
WHERE
    c.id  = 1
GROUP BY cat.id;

Create a PDF with specific page ranges of multiple PDF files?

I have found many related questions in this forum. But, none addresses my issue. Please double-check before marking it as duplicate.

Suppose I have two PDF files.

  1. first.pdf having 10 pages.

  2. second.pdf having 20 pages.

I want to create a new PDF file, where I need pages – 2,5,6,9 from first.pdf and pages 6,7,15,19 from second.pdf.

How to do it from command line?

Is it okay to have multiple aims? [on hold]

From childhood we were told to have only one aim. All the stories we were told were around this concept (for example, Arjuna and Fish Eye from the Mahabharata). If we vacillate between different career options people would advise us to concentrate on only one aim.

But many times is it not possible to have multiple interests or career choices or may be we are not yet able to find our objective? In such cases is it not an good idea to work on all interests or career options or passions?

Can anyone advise on how to decide which field is best (most interesting) for you?

game maker place_meeting multiple objects

I am working on a simple game that contains two objects the player and the ground, and I used place_meeting to make the player walk on the ground object and it works fine but when I try to add another object to make the player walk on it, it didn’t work and the game freeze, here is my code:

// vertical collision
if place_meeting(x,y+vsp,ground1) or place_meeting(x,y+vsp,ground2)
{
while ((!place_meeting(x,y+sign(vsp),ground1 )) or (!place_meeting(x,y+sign(vsp),oground1=2 )))

 y+=sign(vsp);

    if (sign(vsp) ==1)
    {
    grounded = 1;
    }

    vsp =0;

 }
else
{
grounded = 0;
}
y+= vsp;

Where to apply for Multiple Entry Schengen Visa – Germany or Austria?

I’m an Indian national, currently living in the UK on Tier 4 Student Visa (General). I’ve been to Schengen territory once and planning one more trip in coming months as below;

Austria 23rd December, 2018 till 31st December, 2018. (coming back to UK).
The Netherlands from 20th January, 2019 till 24th January, 2019.
Germany from 24th January, 2019 till 4th February, 2019.

In this particular case, where should I make an application? I’m going to spend maximum days in Germany; however, I’ll be returning from Austria without entering Germany and then again going back to Schengen area for more days including The Netherlands and Germany.

I’d really appreciate your help.
Thank you!