我使用了一些子查询,它根本不工作,如果我给它的工作硬编码id。
SELECT
(
SELECT
COUNT(*)
FROM
inventory_set_variations isv
WHERE
isv.c_catid LIKE '%[{"id":"c1.catid"}]%' AND isv.company_id = 1
) AS 'count_total_no_of_variations',
`c1`.`catid` AS `catid`
FROM
category c1
WHERE
(
`c1`.`catsid` <> 3 AND c1.company_id = '1'
)
这不管用,
下面的代码是工作,因为我给硬编码的数据
SELECT
(
SELECT
COUNT(*)
FROM
inventory_set_variations isv
WHERE
isv.c_catid LIKE '%[{"id":"1000020"}]%' AND isv.company_id = 1
) AS 'count_total_no_of_variations',
`c1`.`catid` AS `catid`
FROM
category c1
WHERE
(
`c1`.`catsid` <> 3 AND c1.company_id = '1'
)
1条答案
按热度按时间a1o7rhls1#
你可以用
CONCAT
形成like
条件改变
到