SELECT 
  PI.product_id, 
  F1.id AS file_id, 
  F1.path AS file, 
  (
    SELECT 
      PI1.alt 
    FROM 
      `cscart_products__images` PI1 
    WHERE 
      PI1.original_file_id = F1.id
  ) AS file_alt, 
  F2.id AS big_file_id, 
  F2.path AS big_file, 
  (
    SELECT 
      PI2.alt 
    FROM 
      `cscart_products__images` PI2 
    WHERE 
      PI2.watermark_big_file_id = F2.id
  ) AS big_file_alt, 
  F3.id AS small_file_id, 
  F3.path AS small_file, 
  (
    SELECT 
      PI3.alt 
    FROM 
      `cscart_products__images` PI3 
    WHERE 
      PI3.watermark_small_file_id = F3.id
  ) AS small_file_alt 
FROM 
  `cscart_products__images` AS `PI` 
  LEFT JOIN `files` AS `F1` ON `F1`.`id` = `PI`.`original_file_id` 
  LEFT JOIN `files` AS `F2` ON `F2`.`id` = `PI`.`watermark_big_file_id` 
  LEFT JOIN `files` AS `F3` ON `F3`.`id` = `PI`.`watermark_small_file_id` 
WHERE 
  `PI`.`product_id` = 30251

Query time 0.00071

Result

product_id file_id file file_alt big_file_id big_file big_file_alt small_file_id small_file small_file_alt
30251 367503 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_0351d58d0e8f_30252_294a88586bde_0_b8b5e1729d00_IMG_4541.JPG 367504 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_90a20b3380d4_30252_294a88586bde_0_b8b5e1729d00_IMG_4541.webp 367505 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_16bf12d70204_30252_294a88586bde_0_b8b5e1729d00_IMG_4541.webp
30251 367506 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_480c55d4bfb4_30252_1b763c4a3a22_0_e119cddbe882_IMG_4544.JPG 367507 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_03403e371873_30252_1b763c4a3a22_0_e119cddbe882_IMG_4544.webp 367508 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_213a4ac55eaa_30252_1b763c4a3a22_0_e119cddbe882_IMG_4544.webp
30251 367509 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_e3d90e39b782_30252_d4f0920eb8cc_0_59507e080b68_IMG_4545.JPG 367510 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_0d8adf756819_30252_d4f0920eb8cc_0_59507e080b68_IMG_4545.webp 367511 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_3fb701002065_30252_d4f0920eb8cc_0_59507e080b68_IMG_4545.webp
30251 367512 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_1fdb79c4dff4_30252_c32d5a6a1a9f_0_77f860666136_IMG_4542.JPG 367513 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_2be917e57b11_30252_c32d5a6a1a9f_0_77f860666136_IMG_4542.webp 367514 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_235115a800e5_30252_c32d5a6a1a9f_0_77f860666136_IMG_4542.webp
30251 367515 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_dae240003895_30252_79748df4eb39_0_c80923360c22_IMG_4540.JPG 367516 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_8464be35b887_30252_79748df4eb39_0_c80923360c22_IMG_4540.webp 367517 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_c15adafc639c_30252_79748df4eb39_0_c80923360c22_IMG_4540.webp
30251 367518 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_5d1c64780252_30252_984470139123_0_dae935c390b5_IMG_4543.JPG 367519 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_711e63439b3a_30252_984470139123_0_dae935c390b5_IMG_4543.webp 367520 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_d61df309ad0e_30252_984470139123_0_dae935c390b5_IMG_4543.webp
30251 367521 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_c512d95c7208_30252_97f5660c0ee4_0_dae935c390b5_IMG_4539.JPG 367522 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_97a30c42e343_30252_97f5660c0ee4_0_dae935c390b5_IMG_4539.webp 367524 https://s3.timeweb.cloud/482029f9-prod/products__images/30251_d05f7eba389b_30252_97f5660c0ee4_0_dae935c390b5_IMG_4539.webp