2

I can't understand why sql gave me an error #1064. I just followed the instruction at this
Full Outer Join - Save Output in new table

I tried putting "INSERT" syntax before the "INTO" but the error is the same

SELECT *  
INTO newtable
FROM buyers FULL JOIN product 
ON product.product_id = buyers.product_id

I expect it to run ok, but mysql gave me this error:

"#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 'INTO newtable FROM buyers FULL JOIN product ON product.product_id = buyers.pr' at line 1"

Dharman
  • 30,962
  • 25
  • 85
  • 135

2 Answers2

0

for mysql (phpmyadmin) you need create select (and not select INTO as use in Sqlite)

 create table newtable
 SELECT *  
 FROM buyers FULL JOIN product 
    ON product.product_id = buyers.product_id

but looking to your ON clause instead of a FULL JOIN seems you need INNER or LEFT JOIN

 create table newtable
 SELECT *  
 FROM buyers INNER JOIN product 
    ON product.product_id = buyers.product_id

or create table newtable SELECT *
FROM buyers LEFT JOIN product ON product.product_id = buyers.product_id

depending of exact match or not

or for a cartesain product you should use FULL JOIN this way

 create table newtable
 SELECT *  
 FROM buyers FULL JOIN product 
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
0

Try This One

SELECT *  
FROM newtable
WHERE buyers INNER JOIN product 
ON product.product_id = buyers.product_id

IS THIS DO YOU WANT?