这是我的查询,我实际想要的是通过最常出现的单词来制作搜索结果顺序,而且单词也可以多于一个单词,但是当输入多个单词时它就会破坏。
SELECT *,
(LENGTH(`product_name`) - LENGTH(REPLACE(`product_name`, 'apple', ''))) /
LENGTH('apple') + (LENGTH(`product_name`) - LENGTH(REPLACE(`product_name`,
'iphone', ''))) / LENGTH('iphone') + (LENGTH(`product_s_desc`) -
LENGTH(REPLACE(`product_s_desc`, 'apple', ''))) / LENGTH('apple') +
(LENGTH(`product_s_desc`) - LENGTH(REPLACE(`product_s_desc`, 'iphone',
''))) /
LENGTH('iphone') + (LENGTH(`product_sku`) - LENGTH(REPLACE(`product_sku`,
'apple', ''))) / LENGTH('apple') + (LENGTH(`product_sku`) -
LENGTH(REPLACE(`product_sku`, 'iphone', ''))) / LENGTH('iphone')
`occurences`
FROM `#__virtuemart_products` p, `#__virtuemart_products_".$dblangcode."` l
WHERE (product_name LIKE '%apple%' OR product_name LIKE '%iphone%' AND
product_s_desc LIKE '%apple%' OR product_s_desc LIKE '%iphone%' AND
product_sku LIKE '%apple%' OR product_sku LIKE '%iphone%' )
ORDER BY `occurences` DESC