Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如何修复1064错误_Mysql_Phpmyadmin - Fatal编程技术网

Mysql 如何修复1064错误

Mysql 如何修复1064错误,mysql,phpmyadmin,Mysql,Phpmyadmin,我在尝试连接这两个表时遇到了这个错误 发生数据库错误,错误号:1064 错误: SELECT order.order_id,order.order_total, customer.first_name,customer.last_name FROM order, customer WHERE order.customer_id=customer.customer_id; 您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 近“订单,客户在哪里订单。客户\u i

我在尝试连接这两个表时遇到了这个错误

发生数据库错误,错误号:1064

错误:

SELECT order.order_id,order.order_total,
customer.first_name,customer.last_name FROM order, customer WHERE
order.customer_id=customer.customer_id; 
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 近“订单,客户在哪里订单。客户\u id=客户。客户\u id”在 第2行

查询:

SELECT order.order_id,order.order_total,
customer.first_name,customer.last_name FROM order, customer WHERE
order.customer_id=customer.customer_id; 
文件名:

SELECT order.order_id,order.order_total,
customer.first_name,customer.last_name FROM order, customer WHERE
order.customer_id=customer.customer_id; 
D:\xampp\htdocs\computeleconix2\system\database\DB\u driver.php行 电话:330

“ORDER”是SQL中的保留字。您必须使用反引号对其进行报价:

SELECT 
    `order`.order_id,
    `order`.order_total,
    customer.first_name, customer.last_name 
FROM `order`, customer 
WHERE `order`.customer_id=customer.customer_id 

每种语言都有一些保留词,我们也称之为关键字。我们不能用这些保留字创建变量

这里的表名是'order',order在mysql中是一个保留字,所以它会生成en错误。你有两个选择

  • 按照惯例,不要使用mysql保留字作为表名,这样可以重命名表
  • 若您不想重命名表,那个么将表名放在引号中 而且用户也是这样

    SELECT 
        `order`.order_id,
        `order`.order_total,
        customer.first_name, customer.last_name 
    FROM `order`, customer 
    WHERE `order`.customer_id=customer.customer_id 
    
  • 希望它能帮助你。快乐的编码。

    带JOIN

    SELECT `order`.`order_id`, `order`.`order_total`, `customer`.`first_name`, `customer`.`last_name`
    FROM `order`
    JOIN `customer` ON
    `order`.`customer_id` = `customer`.`customer_id`; 
    
    无连接

    SELECT `order`.`order_id`, `order`. `order_total`,
    `customer`.`first_name`, `customer`.`last_name` 
    FROM `order`, `customer` 
    WHERE `order`.`customer_id` = `customer`.`customer_id`;
    

    试着从订单内部加入订单上的客户。客户id=客户。客户id不起作用@Miladinovic