【发布时间】:2013-04-13 01:42:04
【问题描述】:
我正在尝试在查询中获取日期范围和交易类型。我正在使用 Mysql 数据库在 PHP 中工作。 原来,声明是
("select * from accounting WHERE date between '$startdate' AND
'$enddate'",$prop);
它工作得很好,没有问题@all。但我还需要它来选择数据库中称为事务类型的列。 这是我修改它的方法:
("SELECT date, account, description, Income FROM accounting where
transactiontype = 'Income' and WHERE date between '$startdate' AND
'$enddate' order by date ASC",$prop);
我收到错误消息: 错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“WHERE date between '2012/09/01' AND '2013/04/17' order by date ASC”附近使用正确的语法 查询:SELECT date, account, description, Income FROM accounting where transactiontype = 'Income' and WHERE date between '2012/09/01' AND '2013/04/17' order by date ASC 任何帮助将不胜感激。
【问题讨论】:
-
把第二个放在哪里。 (PS:我没有投反对票)。