Multiple Filtering Against First Keyword?

1 replies
Hi,

I am trying to filter all oak living room furniture. Current I can only filter oak coffee tables. But I am stuck on how to filter oak coffee tables and oak sideboards.

Can anyone advise how I can filter but always using one keyword?

This displays all oak coffee tables.

WHERE linkname LIKE '%oak%' and linkname LIKE '%coffee%'";

This is displays nothing

WHERE linkname LIKE '%oak%' and linkname LIKE '%coffee%' and linkname LIKE '%sideboard%'";

This displays all oak coffee tables and all sideboards of any material.

WHERE linkname LIKE '%oak%' and linkname LIKE '%coffee%' or linkname LIKE '%sideboard%'";
#filtering #keyword #multiple
  • Profile picture of the author 723Media
    Not sure what your database schema looks like but you are being too specific in your query.

    You can get all "oak" furniture by asking for less:

    WHERE linkname LIKE '%oak%'

    That is assuming that linkname is some type of categorization by oak. Making a big assumption, this seems like it should grab all 'oak' furniture.

    Anytime you add AND in your query, you're asking for another matching condition. If you remove it or swap it with OR, then you should be good.
    {{ DiscussionBoard.errors[8424404].message }}

Trending Topics