0

I have a error in my SQL:

"SELECT * FROM tireOverview FULL OUTER JOIN tirePrice ON tireOverview.ID=tirePrice.IDtire"

Where i get this error:

Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 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 'OUTER JOIN tirePrice ON tireOverview.ID=tirePrice.IDtire ORDER BY tireOvervie...' at line 1 in /var/www/html/webscraper/scraper/include.php:158 Stack trace: #0 /var/www/html/webscraper/scraper/include.php(158): PDOStatement->execute() #1 /var/www/html/webscraper/scraper/index.php(34): tireReadOut(Object(PDO)) #2 {main} thrown in /var/www/html/webscraper/scraper/include.php on line 158

My Database consists of 2 tables:

tireOverview -> ID, EAN, ProductName, Date, URLAutoweek

tirePrice -> ID, IDtire (fk tireOverview.ID), Seller(fk Sellers.ID), PriceAutoweek, PositionAutoweek, PriceJSON, LastChanged

I want to get all the data from where tireOverview.ID matches tirePrice.IDtire.

Database is mariaDB, with PHPMyAdmin. Server is Debian 10 (Buster). PHP is version 7.3.

If you need more info, just comment!

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
Zegert
  • 113
  • 10
  • 4
    MySQL/MariaDB does not implement FULL joins. – Akina Nov 03 '20 at 09:24
  • Possible similiar to https://stackoverflow.com/questions/2384298/why-does-mysql-report-a-syntax-error-on-full-outer-join – BhAvik Gajjar Nov 03 '20 at 09:27
  • 1
    In MySQL you should use LEFT OUTER JOIN or RIGHT OUTER JOIN. There is no just OUTER JOIN. If you need FULL OUTER JOIN in MySql you can use UNION of LEFT JOIN and RIGHT JOIN – BhAvik Gajjar Nov 03 '20 at 09:28
  • @BhAvikGajjar Thank you for directing me in the good direction, searched for 30 minutes but didn't find that page. – Zegert Nov 03 '20 at 09:29
  • @Zegert Welcome ! Hope this will help you SELECT * FROM company C LEFT JOIN company_address A ON C.company_id = A.company_id WHERE A.company_id IS NULL – BhAvik Gajjar Nov 03 '20 at 09:30
  • If this is what you want: "I want to get all the data from where tireOverview.ID matches tirePrice.IDtire.", then you merely want an inner join. – Gordon Linoff Nov 03 '20 at 12:05
  • @GordonLinoff You're right! Thanks a lot. – Zegert Nov 03 '20 at 14:13

1 Answers1

0

As Akina said: "MySQL/MariaDB does not implement FULL joins.", but you can do:

SELECT * FROM company C LEFT JOIN company_address A ON C.company_id = A.company_id WHERE A.company_id IS NULL

Sources:

How to do a FULL OUTER JOIN in MySQL?

Why does MySQL report a syntax error on FULL OUTER JOIN?

Credits: @Akina & @BhAvik Gajjar

Zegert
  • 113
  • 10