Thursday 15 July 2010

mysql - Create Table using inner join in sql -



mysql - Create Table using inner join in sql -

i supposed create table in sql using inner bring together , tables. came such solution mysql workbench keeps telling me there error in sql syntax. out of ideas. i'd grateful if help me.

create table bigtable as( select productname, supplierid, categoryid, quantityperunit, unitprice, unitsinstock, unitsonorder, reorderlevel, discontinued `northwind`.`products` inner join( select customerid, employeeid, orderdate, requireddate, shipvia, freight, shipname, shipaddress, shipcity, shipregion, shippostalcode, shipcountry, productid, unitprice, quantity, discount `northwind`.`orders` inner bring together `northwind`.`order_details` on orders.orderid=order_details.orderid) products inner join( select lastname, firstname ,title ,titleofcourtesy ,birthdate ,hiredate ,address ,city , region, postalcode, country, homephone, extension, photo, notes, reportsto, companyname,contactname,contacttitle,address,city,region,postalcode,country,phone,fax, `northwind`.`employees` inner bring together `northwind`.`customers`) people));

get rid of outer set of parentheses. should be:

create table bigtable select productname, supplierid, categoryid, quantityperunit, unitprice, unitsinstock, unitsonorder, reorderlevel, discontinued `northwind`.`products` inner join( select customerid, employeeid, orderdate, requireddate, shipvia, freight, shipname, shipaddress, shipcity, shipregion, shippostalcode, shipcountry, productid, unitprice, quantity, discount `northwind`.`orders` inner bring together `northwind`.`order_details` on orders.orderid=order_details.orderid) products inner join( select lastname, firstname ,title ,titleofcourtesy ,birthdate ,hiredate ,address ,city , region, postalcode, country, homephone, extension, photo, notes, reportsto, companyname,contactname,contacttitle,address,city,region,postalcode,country,phone,fax `northwind`.`employees` inner bring together `northwind`.`customers`) people;

you had mismatched parentheses, since had 2 )) @ end matching opening (, , , after fax.

these prepare syntax errors. looks have logic errors, of inner join clauses missing on conditions relate tables. , you're selecting lots of columns never use.

mysql join mysql-workbench

No comments:

Post a Comment