Comparison SQL always return false
Hi, I use MySQL 5.0 with perl (the latest version) in FreeBSD 5.3. I found that if I assign a hard coded string (with double quote) to the string variable which in turns become part of the SQL statement, the SQL does return result. If I assign a value which is return from an array in perl (eg. @array[1]) and use this variable in the SQL statement, the SQL does not return any result. For example: The following code does not return any result my $mycustcode = @outlets[1]; # this array contains string 07-2-0057 However, if I use the following hard coded assignment, the SQL statement returns result: # my $mycustcode = 07-2-0057; $create_view_sql = qq {create view $viewtab as select c.custcode, c.custname, c.type, sum(t.netsales) as sales from customer c, transaction t where c.custcode = t.custcode and date(t.date) = $start_date and date(t.date) = $end_date and (c.type = EXPORT or c.type = LOCAL) and (c.custcode = $mycustcode) group by c.custcode;}; I may be using incorrect way to split the tokens, here is the function to extract a list of the token: $outlet_str = $in{'outlets'} Thanks Sam -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Comparison SQL always return false
sam wun wrote: Hi, I use MySQL 5.0 with perl (the latest version) in FreeBSD 5.3. I found that if I assign a hard coded string (with double quote) to the string variable which in turns become part of the SQL statement, the SQL does return result. If I assign a value which is return from an array in perl (eg. @array[1]) and use this variable in the SQL statement, the SQL does not return any result. $array[1] not @array[1]. For example: The following code does not return any result my $mycustcode = @outlets[1]; # this array contains string 07-2-0057 However, if I use the following hard coded assignment, the SQL statement returns result: # my $mycustcode = 07-2-0057; $create_view_sql = qq {create view $viewtab as select c.custcode, c.custname, c.type, sum(t.netsales) as sales from customer c, transaction t where c.custcode = t.custcode and date(t.date) = $start_date and date(t.date) = $end_date and (c.type = EXPORT or c.type = LOCAL) and (c.custcode = $mycustcode) group by c.custcode;}; I may be using incorrect way to split the tokens, here is the function to extract a list of the token: $outlet_str = $in{'outlets'} Thanks Sam -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]