in reply to DBI and like statment

Hm, I'm thinking that the resultant $sql isn't what you expect it to be. Add a
warn $sql;
after you build your $sql and see if it's what you think it should be. If that doesn't work, try escaping like this:
my $sql = "select title from $TABLE2 where astype like '%\Q$query\E'";