79107078

Date: 2024-10-20 12:59:08
Score: 2
Natty:
Report link

thanks for all helps, temporary i used this way just with change gr300 to any product code as i want or change to variable,good luck.

WITH RECURSIVE ctags AS (
SELECT
    id,
    producttitle,
    tags,
    productcode,
    instr(tags, ',') AS pos,
    substr(tags, 1, instr(tags, ',') - 1) AS tag_value,
    substr(tags, instr(tags, ',') + 1) AS rest
FROM
    tblproduct
WHERE
    productcode = 'gr300'

UNION ALL

SELECT
    id,
    producttitle,
    tags,
    productcode,
    instr(rest, ',') AS pos,
    CASE
        WHEN instr(rest, ',') = 0 THEN rest
        ELSE substr(rest, 1, instr(rest, ',') - 1)
    END AS tag_value,
    CASE
        WHEN instr(rest, ',') = 0 THEN ''
        ELSE substr(rest, instr(rest, ',') + 1)
    END AS rest
FROM
    ctags
WHERE
    rest <> ''
)

SELECT DISTINCT
    p.id,
    p.producttitle,
    p.productcode,
    p.tags
FROM
    tblproduct p
JOIN
    ctags t ON p.tags LIKE '%' || t.tag_value || '%' AND p.productcode <> 'gr300'
Reasons:
  • Blacklisted phrase (0.5): thanks
  • RegEx Blacklisted phrase (1): i want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: persi