Let's say I have such SQL query which I make to PostgreSQL database. As you can see I'm repeating the same subquery just to get another column. I am convinced that this is ineffective. What is the best way to execute an sql query for your opinion?
SELECT
TABLE_A.COLUMN_1,
TABLE_A.COLUMN_2,
(
SELECT
TABLE_B.COLUMN_A,
FROM
TABLE_B
WHERE
TABLE_B.COLUMN_Z ILIKE CONCAT('%', TABLE_A.COLUMN_2, '%')
) AS COLUMN_3,
(
SELECT
TABLE_B.COLUMN_B,
FROM
TABLE_B
WHERE
TABLE_B.COLUMN_Z ILIKE CONCAT('%', TABLE_A.COLUMN_2, '%')
) AS COLUMN_4,
FROM
TABLE_A