PERL中的SQL group by和where子句

时间:2017-08-14 06:59:02

标签: perl

无法执行此代码......

use strict;
use warnings;

my $qstr = "select id as 'id', 
                   status as 'status', 
                   $subject.title as 'title', 
                   $subject.component as 'component', 
                   $subject.submitted_date as 'submitted_date', 
                   $subject.closed_date as 'closed_date' 
             where ($subject.title like 'PM_Production' 
               and ($subject.status = 'complete' 
                 OR $subject.status = 'rejected'))";
my $results = &search($api, $tenant, $subject, $qstr); 

foreach my $singleRow (@$results) {
    my $title =$singleRow->{'title'};
    my $component = $singleRow->{'component'};
    my $sub_date = $singleRow->{'submitted_date'};
    my $closed_date = $singleRow->{'closed_date'};

    print "$title, $component, $sub_date, $closed_date\n";
}

有如下错误;

Syntax Error

 -- Error 15: Invalid Operator Found: "like"

预期输出:希望过滤标题包含的所有数据" PM_Pro"

P.S。数据标题示例:

 Title             Ticket Submitted_date      Ticket closed_date
 PM_Pro_test1      2017-05-11 12:47:08.2      2017-05-26 07:00:16.0
 PM_Pro_test2      2017-05-11 13:23:10.96     2017-05-27 22:01:02.0
 Testi_PM_Pro      2017-05-11 13:23:02.483    2017-05-24 08:10:20.0
 Testii_PM_Pro     2017-05-11 13:28:35.247    2017-05-24 08:12:33.0 

1 个答案:

答案 0 :(得分:2)

首先,您的列别名应使用双引号引用或不加引号。

其次,没有FROM子句(类似“FROM $ subject”)。

第三,看起来你需要=运算符而不是LIKE。

看起来你想写类似

的东西
<button ion-fab color="danger" (click)="share()" name="share" alt="Share" role="presentation">
  <ion-icon name="md-share" ></ion-icon>
</button>