" SELECT `a`.`id`,`a`.`inquiry_no`,`a`.`type`,`a`.`is_multi`,`a`.`status`,`a`.`bank_name`,`a`.`sub_bank_name`,`a`.`branch_bank_name`,`a`.`customer_name`,`a`.`create_time`,`a`.`buss_username`,`a`.`estimate_no`,`a`.`evaluate_purpose`,`a`.`time_length`,a.business_no AS business_no,b.id as did,`b`.`inquiry_id`,`b`.`city`,`b`.`city_id`,`b`.`full_estate_name`,`b`.`size`,b.usage AS usage,`b`.`register_price`,`d`.`inquiry_detail`,d.appraiser_name AS response_username,`d`.`appraiser_id`,`d`.`appraise_level`,d.create_time AS response_time,`d`.`assessment_price`,`d`.`assessment_all_value`,`d`.`assessment_net_worth`,`d`.`assessment_net_worth_tow`,`d`.`total_tax1`,`d`.`total_tax2`,`d`.`internal_remarks`,d.id AS rid FROM `pg_inquiry` `a` LEFT JOIN `pg_inquiry_detail` `b` ON `b`.`inquiry_id`=`a`.`id` LEFT JOIN `pg_return_price` `d` ON `b`.`id`=`d`.`inquiry_detail` WHERE `a`.`status` > 0 AND `a`.`create_time` BETWEEN '2023-03-02 00:00:00' AND '2023-05-31 23:59:59' AND `is_simple` = 0 AND `is_automatic` = 0 ORDER BY `a`.`create_time` DESC,`d`.`create_time` DESC "报错:SQLSTATE[42000]: Syntax error or access violation: 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 'usage, business_no, buss_username, ' at line 13,解决方法是什么
时间: 2023-10-17 09:01:58 浏览: 149
看起来 SQL 查询语句中有一个问题,'usage' 是 MySQL 中的保留关键字,不能用作列名。为了解决这个问题,可以将 'usage' 重命名为其他名称,例如 'property_usage'。修改后的 SQL 查询语句如下:
SELECT `a`.`id`,`a`.`inquiry_no`,`a`.`type`,`a`.`is_multi`,`a`.`status`,`a`.`bank_name`,`a`.`sub_bank_name`,`a`.`branch_bank_name`,`a`.`customer_name`,`a`.`create_time`,`a`.`buss_username`,`a`.`estimate_no`,`a`.`evaluate_purpose`,`a`.`time_length`,a.business_no AS business_no,b.id as did,`b`.`inquiry_id`,`b`.`city`,`b`.`city_id`,`b`.`full_estate_name`,`b`.`size`,`b`.`property_usage`,`b`.`register_price`,`d`.`inquiry_detail`,d.appraiser_name AS response_username,`d`.`appraiser_id`,`d`.`appraise_level`,d.create_time AS response_time,`d`.`assessment_price`,`d`.`assessment_all_value`,`d`.`assessment_net_worth`,`d`.`assessment_net_worth_tow`,`d`.`total_tax1`,`d`.`total_tax2`,`d`.`internal_remarks`,d.id AS rid FROM `pg_inquiry` `a` LEFT JOIN `pg_inquiry_detail` `b` ON `b`.`inquiry_id`=`a`.`id` LEFT JOIN `pg_return_price` `d` ON `b`.`id`=`d`.`inquiry_detail` WHERE `a`.`status` > 0 AND `a`.`create_time` BETWEEN '2023-03-02 00:00:00' AND '2023-05-31 23:59:59' AND `is_simple` = 0 AND `is_automatic` = 0 ORDER BY `a`.`create_time` DESC,`d`.`create_time` DESC
阅读全文