php - 使用 PHP 和 MySQL 在 sql 查询中获取语法错误

标签 php mysql

我在使用 MySQL 查询时遇到以下错误。

Error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'o.user_id='RNAYAK2009@GMAIL.COM' and (o.status='Successful' or o.status='Pending' at line 1

我在下面解释我的查询。

SELECT o.order_id,o.order_date,o.payment_amount,
       o.status,op.pro_data_id,pd.image,pd.pro_Id,pi.Product_name
FROM db_order AS o
LEFT JOIN db_order_products AS op ON o.order_id = op.order_id 
LEFT JOIN db_product_data AS pd ON op.pro_data_id=pd.pro_data_id 
LEFT JOIN db_product_info AS pi ON pd.pro_Id=pi.pro_Id 
WHERE o.user_id='RNAYAK2009@GMAIL.COM' 
    and (o.status='Successful' or o.status='Pending')

请帮我解决这个错误。

最佳答案

您可能需要重新粘贴它,但看起来您粘贴的内容有两个错误:

pi.  Product_name

pi.pro_IdWHERE

关于php - 使用 PHP 和 MySQL 在 sql 查询中获取语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35717096/

相关文章:

php - Mysql 总和之前的行

mysql - MYSQL 5.7 中的 native JSON 支持 : what are the pros and cons of JSON data type in MYSQL?

php - 我如何为一个类别实现这个基本 CSS?

javascript - 添加所选类的相对 URL

使用 CSS 类的 PHP header 新页面

php - 如何在管理端 OpenCart 中打印友好的 url

php - 如何在 PHP 中捕获未设置的 REQUEST 值

php - Yii 框架 : No Database selected

mysql - SQL查询: How to Get tweet from following?

MySQL 连接查询 - 如何处理 3 个表?