任何人都可以告诉我这个查询有什么问题

时间:2017-04-11 08:42:01

标签: php postgresql

我有参数prom http import_me.py这个查询,但它不起作用。任何人都可以告诉我它有什么问题。

$_POST

错误说

  if ($category != 'All' && $status !='All' && $name !='All'){
                 $query = "SELECT " .$select." FROM afro_fixed_asset  WHERE fixed_asset_category = '".$category."'AND fixed_asset_status= '".$status."' AND fixed_asset_acquisition_date BETWEEN '".$acquisition_from."' AND '".$acquisition_to."'"."' AND fixed_asset_registered_date BETWEEN '".$registration_from."' AND '".$registration_to."'";
                }

4 个答案:

答案 0 :(得分:0)

首先,请使用prepared statements。这将解决这个问题。

其次,你的问题在这里:

SpringApplication.setBanner(…​)

您添加了两个... AND '".$acquisition_to."'"."' ... 字符,编辑显示如下:

'

答案 1 :(得分:0)

解决方案非常简单,您的查询在结尾处有一个'太多:

SELECT fixed_asset_id,fixed_asset_name,fixed_asset_category,fixed_asset_status 
FROM afro_fixed_asset 
WHERE fixed_asset_status = 'Operational (In use)' 
AND fixed_asset_category= 'Computer & Computer Accessory' 
AND fixed_asset_name= 'Bur Cutter' 
AND fixed_asset_acquisition_date BETWEEN '03/26/2017' 
AND '03/27/2017'' // Error here, one ' too much
AND fixed_asset_registered_date BETWEEN '04/12/2017'' AND '04/03/2017'

答案 2 :(得分:0)

正确的查询

$query = "SELECT " .$select." FROM afro_fixed_asset  WHERE fixed_asset_status = '".$status."' AND fixed_asset_category= '".$category."' AND fixed_asset_name= '".$name."' AND fixed_asset_acquisition_date BETWEEN '".$acquisition_from."' AND '".$acquisition_to."' AND fixed_asset_registered_date BETWEEN '".$registration_from."' AND '".$registration_to."'";

答案 3 :(得分:0)

您之前有额外的sigle引用--- - hosts: test tasks: - block: - name: task 1 shell: "echo {{item}}" with_items: - one - two 并且您可以看到'".$registration_from."'"."' AND "并且您已经将单引号与"'"联系起来。如果你删除你的查询将正常工作。