dimanche 24 juillet 2016

Singular or Plural word search in MySQL

i have table

 CREATE TABLE IF NOT EXISTS `posts` (
      `post_id` int(11) NOT NULL,
      `post_slug` text CHARACTER SET utf8 NOT NULL,
      `title` longtext CHARACTER SET utf8 NOT NULL,
      `created_at` date NOT NULL,
      `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;

i am implementing search on this table.say example i have a number of posts in which i am searching Keyword "Art" when i searched for "art" it's working fine .i am getting all art having art in their title but when i search for "Arts" i am not getting any records as there is a no posts that contains "arts" in their title.the keyword is not fixed.it's user keyword that user will search for what i have tried is below query :

SELECT * 
FROM `posts` 
WHERE title LIKE "%art%" 
ORDER BY `post_id` ASC

Aucun commentaire:

Enregistrer un commentaire