CREATE TABLE articles ( id int(11) NOT NULL default '0', title varchar(65) NOT NULL default '', bodytext text NOT NULL, PRIMARY KEY (id) ) TYPE=MyISAM; #### my @terms = split( / /, $search_terms ); my $querystr = "select id,title,bodytext from articles where "; my $count = 0; foreach my $term ( @terms ) { if ( $count ) { $querystr .= " or "; } $querystr .= "bodytext like '%$term%' "; $count++; } $querystr .= "order by id desc"; # Do the execution my $query = $db->prepare( $querystr ); $query->execute();