Skip to content
Advertisement

Multiple inner joins in pymysql

I am attempting to select multiple columns from three tables in pymysql, and inner join them. I don’t understand what is going wrong when I add the second inner join. I feel like it’s a simple syntax mistake, but I just can’t see it.

This works.

This doesn’t work, and I can’t see the mistake.

The resulting error

ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘FROM ADMISSIONS as a INNER JOIN PATIENTS as p ON a.SUBJECT_ID=p.SUBJECT_IDnFROM ‘ at line 2”)

Advertisement

Answer

MySQL error messages are very exact. They point directly to the (first) problem.

Remove the comma

But after the join you try to select from another table. That won’t work. You have to join them all.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement