我有嚴重的問題,我想要的解決方案。在varchar和text中的數據類型提取記錄單數和pural明智
我想從數據庫中獲取記錄。 例如:當我在尋找鉛筆然後我會得到4條記錄,當我將搜索鉛筆然後我會得到15條記錄。 但我想要15個記錄,如果它由鉛筆或鉛筆搜索。
這是MySQL查詢:
SELECT DISTINCT
gc_products.name,
gc_products.*,
LEAST(IFNULL(NULLIF(saleprice, 0), price),
price) AS sort_price
FROM
(`gc_products`)
JOIN
`gc_group_product` ON `gc_group_product`.`product_id` = `gc_products`.`id`
JOIN
`gc_category_products` ON `gc_category_products`.`product_id` = `gc_products`.`id`
JOIN
`gc_categories` ON `gc_categories`.`id` = `gc_category_products`.`category_id`
WHERE
`gc_products`.`enabled` = 1
AND `gc_group_product`.`group_id` = 5
AND (gc_products.name LIKE '%pencils%'
OR gc_products.description LIKE '%pencils%'
OR gc_products.excerpt LIKE '%pencils%'
OR gc_products.sku LIKE '%pencils%')
OR (gc_categories.name LIKE '%pencils%'
OR gc_categories.excerpt LIKE '%pencils%');
我希望我得到的答覆
感謝
您向我們展示了鉛筆的查詢,但鉛筆呢? –
您可以從我們要搜索的關鍵字中刪除「s」 –
也許您在尋找[全文搜索](http://dev.mysql.com/doc/refman/5.7/zh/fulltext-search html的)? –