X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fh_Common.pm;h=87fb76da209f4750810f8509833b5f78a1e8a236;hp=9b5ad09d9ad22ef52409c0ebef8dffaea4c538e5;hb=a36e0f8a0f69349dafaa16d1d2d57dfb6e5dbc85;hpb=706da330626bab472bf6f4e50cf3c181bfa0cf9f diff --git a/FS/FS/h_Common.pm b/FS/FS/h_Common.pm index 9b5ad09d9..87fb76da2 100644 --- a/FS/FS/h_Common.pm +++ b/FS/FS/h_Common.pm @@ -52,19 +52,19 @@ sub sql_h_search { my( $notdeleted, $notdeleted_mr ) = ( '', '' ); if ( scalar(@_) && $_[0] ) { $notdeleted = - "AND 0 = ( SELECT COUNT(*) FROM $table as notdel - WHERE notdel.$pkey = maintable.$pkey - AND notdel.history_action = 'delete' - AND notdel.history_date > maintable.history_date - AND notdel.history_date <= $_[0] - )"; + "AND NOT EXISTS ( SELECT 1 FROM $table as notdel + WHERE notdel.$pkey = maintable.$pkey + AND notdel.history_action = 'delete' + AND notdel.history_date > maintable.history_date + AND notdel.history_date <= $_[0] + )"; $notdeleted_mr = - "AND 0 = ( SELECT COUNT(*) FROM $table as notdel_mr - WHERE notdel_mr.$pkey = mostrecent.$pkey - AND notdel_mr.history_action = 'delete' - AND notdel_mr.history_date > mostrecent.history_date - AND notdel_mr.history_date <= $_[0] - )"; + "AND NOT EXISTS ( SELECT 1 FROM $table as notdel_mr + WHERE notdel_mr.$pkey = mostrecent.$pkey + AND notdel_mr.history_action = 'delete' + AND notdel_mr.history_date > mostrecent.history_date + AND notdel_mr.history_date <= $_[0] + )"; } (