mysql - SQL错误1064,语法错误

标签 mysql sql

我有一个sql查询

Select * from `products`
where (`product_company`='mad over donuts' OR
       `product_company`= 'dunkin donuts')
AND (`flavour`='vanilla')
AND (355 < `price` < 561 ) ;

它获取大于某个固定价格和小于某个固定价格的元素。它还包括其他约束。但是,当我运行此 sql 查询时,它给了我一个

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 '"Select * from products where (product_company='mad over donuts' OR `product' at line 1.

我检查了我的 sql 语法,我似乎没有发现问题。有人吗?

最佳答案

代替这个

Select * from `products`
where (`product_company`='mad over donuts' OR
       `product_company`= 'dunkin donuts')
AND (`flavour`='vanilla')
AND (355 < `price` < 561 )";

"导致问题

试试这个

Select * from `products`
where (`product_company`='mad over donuts' OR
       `product_company`= 'dunkin donuts')
AND (`flavour`='vanilla')
AND (`price`BETWEEN 355 and 561 );

关于mysql - SQL错误1064,语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35946537/

相关文章:

jquery - 浏览器如何能够记住输入字段?

php - 动态获取不同关联行的旧列值(在 Laravel 中)

c# - 将数据表转换为哈希表或将 sqldatareader 转换为哈希表的简便方法

sql - Visual Studio 2010 中 "Run"和 "Run On"命令的 VS2010 宏/插件

mysql - 从 PHP 将日期存储在 MySQL 中的最佳实践

php - 如何发布mysql脚本

sql - 在多对多 SQL 表中查找数据关系或图形

sql - 是否应该为 SQL Server 2005 中的存储过程授予 CONTROL 权限?

mysql - Mysql TO_DATE FUNCTION 在 CREATE TABLE 中不起作用

mysql - 我如何从 MySQL 中的 CASE 语句中获取结果?