0

Have a bit of a strange query request for our MySQL database.

Table "product" is like this:

brandid int
shopid int
name varchar(255)

name is always 1+ words separated by " ". For example "Lenovo laptop X1".

I need to get the all the words that appears in names for 2+ brandid and 2+ shopid (i.e. to be selected, a word must appear in products for at least 2 different brandid's and at least 2 different shopids's).

Someone got an idea for writing such a query?

PS: Performance is not critical, but it might be worth mentioning that the table has ~3 million rows...

Louisa
  • 552
  • 1
  • 9
  • 22
  • Take a look here: http://stackoverflow.com/questions/13159526/split-values-over-multiple-rows to see how you can split the names to rows per word. once you have this, the rest should be pretty simple – Nir Levy Sep 09 '16 at 11:46
  • MATCH AGAINST https://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html – Deep Sep 09 '16 at 12:23

0 Answers0