There are two tables: slider_media enter image description here slider_slides

enter image description here

How to write select to get on output:

slide_id - id из таблицы slider_slides; desktop_image_url - name из таблицы slider_media; mobile_image_url - name из таблицы slider_media; title; link; priority; 

I know that something with joins somehow but something does not work.

I will be very grateful

  • What are these fields: slide_id , desktop_image_url , mobile_image_url ? What tables - robertobadjio
  • Sori, forgot to sign the tables, slide_id: this is from the second screen - id desktop_image_url: this is from the first screen - name - russell
  • What is the field of contact? - robertobadjio
  • the id from the slider_media table is slider_media into the mobile_id field the same in the mobile_id field - russell

1 answer 1

 SELECT ss.id AS slide_id, sm1.name AS desktop_image_url, sm2.name AS mobile_image_url, ss.title, ss.link, ss.priority FROM slider_slider ss LEFT JOIN slider_media sm1 ON sm1.desktop_id = ss.id LEFT JOIN slider_media sm2 ON sm1.mobile_id = ss.id 
  • @russell If the problem is solved, put the "issue resolved" - robertobadjio
  • What is sm1 and sm2 ? ss I understand slider_slides and sm is slider_media - russell
  • Thanks, thanks to your example, figured out, works - russell
  • one
    sm1 , sm2 , ss are table aliases - robertobadjio