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

Joining tables on two columns

How do I join these two tables on ServiceContract and LogicalAdress? When I try LEFT JOIN I end up with way more rows than there initially are.

https://www.db-fiddle.com/f/a8ZiSmfx8iTMe4kwEtfSsb/1

I’ve tried the query below but it gives me "Query Error: Error: ER_BAD_FIELD_ERROR: Unknown column ‘ServiceContract’ in ‘from clause’".

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

SELECT * 
FROM `ServiceErrorsProd`
JOIN `ServiceProductions` USING (ServiceContract, LogicalAdress)

>Solution :

The error reported by that query is actually:

Query Error: Error: ER_BAD_FIELD_ERROR: Unknown column ‘a.LogicalAdress’ in ‘on clause’

This line:

`LogicalAdress ` varchar(53) DEFAULT NULL,
              ^ extra space

Should be:

`LogicalAdress` varchar(53) DEFAULT NULL,

Delimited identifiers allows you to have identifiers with characters normally not allowed, including whitespace.

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