Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

why I am getting syntax error when using select?

I get this error:

ERROR:  42601: syntax error at or near "ON"
LINE 23:       ce.image from cars_images ce ON (c.id = ce.car_id)) as images

here is my code:

   SELECT

    c.id,
    c.model,
    c.description,
    c.environment,
    c.equipment,
    c.ps,
    c.tuv,
    c.cover,
    c.brand,
    c.price,
    c.engine,
    c.fuel,
    c.firstregistration,
    c.km,
    c.color,
    c.video,
    c.type,
    c.show,
    c.sit_place,
    (select
      ce.image from cars_images ce ON (c.id = ce.car_id)) as images
    
    FROM cars c


   GROUP BY c.id

   limit 100

what I am doing wrong on my subquery ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have googled but not found I saw the same subquery on others but idk why my it is not working

>Solution :

You are missing a join. Don’t use ON without a join.

you probably want a WHERE instead

select
      ce.image from cars_images ce WHERE (c.id = ce.car_id)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading