If I may suggest as well, doing this using sprintf is not ideal. Using placeholders is always a better idea:
my $sql = q{ SELECT `Cats`.`Name`, `Address`.`Address`, `Address`.`City`, `Contact`.`Phone`, `Keys`.`Keywords` FROM ( `Cats` LEFT JOIN `Address` USING (`Name`) LEFT JOIN `Contact` USING (`Name`) LEFT JOIN `Keys` USING (`Name`) ) WHERE `Keys`.`Keywords` LIKE ? ORDER BY `Cats`.`Name` asc LIMIT ?,? }; # get the statement handle, assuming a valid DBI object in $dbh my $sth = $dbh->prepare( $sql ); $sth->execute( '%'.$search.'%', $start - 1, $per_page + 1 );
You also had the "order by" clause stating name. I would have thought that'd be an error since you're not specifying the table in a join. I've changed it to `Cats`.`Name`.
update: I'm an idiot. Fixed execute syntax.
In reply to Re: PERL and MySQL
by meraxes
in thread PERL and MySQL
by JimJx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |