有人知道为什么会有语法错误吗?我想里面没有保留词吧?
指挥部

cmd.CommandText = "SELECT ordertable._name, ordertable.quantity, food_menu.food_price, beverage_menu.beverage_price" +
                         "FROM ordertable" +
                         "INNER JOIN food_menu ON ordertable._name = food.foodname" +
                         "INNER JOIN beverage_menu ON beverage_menu.beverage_name' = ordertable._name" +
                         "WHERE ordertable.tablenum = '1'";

错误:
SQL语法中有错误;请查看手册
对应于MySQL服务器版本,以便使用正确的语法
在ordertable上的“JOIN food”菜单附近。name=food.foodnameINNER JOIN
1号线be'上的饮料菜单

最佳答案

您缺少空格。此时,您的查询将类似于FROM ordertableINNER JOIN food_menu ...。您可以使用多行语法来简化它

cmd.CommandText = @"SELECT ordertable._name, ordertable.quantity, food_menu.food_price, beverage_menu.beverage_price
                         FROM ordertable
                         INNER JOIN food_menu ON ordertable._name = food_menu.foodname
                         INNER JOIN beverage_menu ON beverage_menu.beverage_name = ordertable._name
                         WHERE ordertable.tablenum = 1";

关于c# - C#中的MySQL内部连接语法错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31218697/

10-10 06:35