MySQL delete with nested select query

后端 未结 2 1661
情话喂你
情话喂你 2021-02-20 02:37

I have the following MySQL query:

DELETE FROM catalogue 
WHERE catalogue_id IN (
  SELECT catalogue_id 
  FROM catalogue 
  WHERE (
    product_id = (SELECT prod         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-20 02:57

    Perform double nesting

    DELETE FROM catalogue 
    WHERE catalogue_id IN (SELECT catalogue_id FROM (
      SELECT catalogue_id 
      FROM catalogue 
      WHERE (
        product_id = (SELECT product_id FROM catalogue WHERE catalogue_id = '2290') 
        AND length_id = (SELECT length_id FROM catalogue WHERE catalogue_id = '2290') 
        AND gauge_id = (SELECT gauge_id FROM catalogue WHERE catalogue_id = '2290')
      )) x
    )
    

    It fools mysql

提交回复
热议问题