使用where子句插入多个SELECT

时间:2014-11-29 09:10:05

标签: mysql

SQL下面给出了错误

  

您的SQL语法有错误;查看与您的MySQL服务器版本相对应的手册,以便在订单附近使用正确的语法(customerid,' customeremail',' customerphone',restaurantid,' restaurantem& #39;第1行

INSERT into Order (customerid, 'customeremail', 'customerphone', restaurantid, 'restaurantemail', 'restaurantphone', dishid, 'dishname', price, timestamp, 'deliverystatus', qualityratings, deliveryratings, 'dishcomments') values 
 Select Cus.idCustomer, Cus.email, Cus.cell, Src.idSource, Src.email, Src.telephone, Dis.idDish, Dis.description, Dis.price, current_timestamp, 5, 5, 'Comments'
  From (Select idCustomer, email, cell, row_number() Over(order by (1)) as RowNum From Customer WHERE email='A.B@gmail.com') Cus
   Join (Select idSource, email, telephone, row_number() Over(order by (1)) as RowNum From FROM Source WHERE idSource = '1') Src
    ON Cus.RowNum = Src.RowNum
   Join (Select idDish, description, price, row_number() Over(order by (1)) as RowNum From Dish WHERE  idDish = '3') Dis
    ON Src.RowNum = Dis.RowNum

1 个答案:

答案 0 :(得分:0)

订单是您的表名?我不认为这是一个明智的选择......它是SQL中的保留字(Order By ...)

@Abhik Chakraborty建议你反击它。我认为您应该将名称更改为Orders以避免混淆。