>当我执行此查询时
SELECT
tbcategory.CATEGORY_ID,
tbcategory.VENDOR_ID,
tbcategory.CATEGORY_NAME,
tbsubcategory.SUB_CATEGORY_ID,
tbsubcategory.SUB_CATEGORY_NAME,
PRODUCT_ID,
PRODUCT_NAME,
PRODUCT_DESC,
GENERAL_PRICE,
RESELLER_PRICE,
SPECIAL_PRICE,
PRODUCT_SHOT_DESC,
MANUFACTURE_PART_NUM,
SKU_ID,
IMAGE
FROM
tbproduct,
tbcategory,
tbsubcategory
WHERE
tbsubcategory.CATEGORY_ID = tbcategory.CATEGORY_ID
AND tbsubcategory.SUB_CATEGORY_ID = tbproduct.SUBCATEGORY_ID
AND tbcategory.CATEGORY_ID IN (SELECT
tbcategory . *
FROM
tbcategory
JOIN
tbcustomer ON FIND_IN_SET(tbcategory.CATEGORY_ID,
tbcustomer.ASSIGNED_CATEGORIES)
WHERE
USER_NAME = 'clark' AND password = '420' UNION SELECT
CATEGORY_ID
FROM
tbcategory,
tbvendor
WHERE
tbvendor.USER_NAME = 'wong'
AND tbvendor.PASSWORD = '143'
AND tbvendor.VENDOR_ID = tbcategory.VENDOR_ID)
ORDER BY tbcategory.CATEGORY_ID , tbsubcategory.SUB_CATEGORY_ID , tbproduct.PRODUCT_ID;
我收到错误代码:1241操作数应包含 1 列
在子查询中,您应该选择一列以与类别 ID 匹配
AND tbcategory.CATEGORY_ID IN
(SELECT
tbcategory.CATEGORY_ID <----- here
FROM
tbcategory
JOIN tbcustomer
ON FIND_IN_SET(
tbcategory.CATEGORY_ID,
tbcustomer.ASSIGNED_CATEGORIES
) .....