SELECT 
  t.tag_id 
FROM 
  tmall_tags AS t 
  INNER JOIN tmall_tag_links AS tl ON t.tag_id = tl.tag_id 
  INNER JOIN tmall_products AS p ON p.product_id = tl.object_id 
  AND tl.object_type = "P" 
  AND p.status = "A" 
  INNER JOIN tmall_products_categories AS pc ON pc.product_id = p.product_id 
  INNER JOIN tmall_categories AS c ON c.category_id = pc.category_id 
  AND c.status = "A" 
WHERE 
  t.status = "A"

Query time 0.00960

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.314765347,
    "nested_loop": [
      {
        "table": {
          "table_name": "t",
          "access_type": "ALL",
          "possible_keys": ["PRIMARY"],
          "loops": 1,
          "rows": 4,
          "cost": 0.01066122,
          "filtered": 100,
          "attached_condition": "t.`status` = 'A'"
        }
      },
      {
        "table": {
          "table_name": "tl",
          "access_type": "ref",
          "possible_keys": ["PRIMARY", "tag_id", "ids"],
          "key": "ids",
          "key_length": "6",
          "used_key_parts": ["tag_id", "object_type"],
          "ref": ["tmall.t.tag_id", "const"],
          "loops": 4,
          "rows": 2,
          "cost": 0.003692328,
          "filtered": 98.91304016,
          "attached_condition": "tl.object_type = 'P'",
          "using_index": true
        }
      },
      {
        "table": {
          "table_name": "p",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "status"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "ref": ["tmall.tl.object_id"],
          "loops": 9.1,
          "rows": 1,
          "cost": 0.015938937,
          "filtered": 93.65079498,
          "attached_condition": "p.`status` = 'A'"
        }
      },
      {
        "table": {
          "table_name": "pc",
          "access_type": "ref",
          "possible_keys": ["PRIMARY", "pt"],
          "key": "pt",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "ref": ["tmall.tl.object_id"],
          "loops": 8.522222222,
          "rows": 11,
          "cost": 0.121089988,
          "filtered": 100
        }
      },
      {
        "table": {
          "table_name": "c",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "p_category_id"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["category_id"],
          "ref": ["tmall.pc.category_id"],
          "loops": 94.37572016,
          "rows": 1,
          "cost": 0.163382874,
          "filtered": 100,
          "attached_condition": "c.`status` = 'A'"
        }
      }
    ]
  }
}

Result

tag_id
1
1
1
1
2
2
2
2
2
2
3
3
3