SELECT 
  c.*, 
  IF (c.location_id != 38, 0, 1) as `default` 
FROM 
  cscart_bm_containers as c 
  INNER JOIN cscart_bm_locations as l ON c.location_id = l.location_id 
  AND l.is_default = 1 
  AND l.layout_id = 2 
WHERE 
  1 
  AND c.position IN ('TOP_PANEL', 'HEADER', 'FOOTER')

Query time 0.00029

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE l ALL PRIMARY 90 Using where
1 SIMPLE c ref location_id,location_id_company_id,location_id_position_company_id location_id 3 toolboxdigitalshop_dev.l.location_id 2 Using where

Result

container_id location_id position width user_class linked_to_default status company_id default
51 14 TOP_PANEL 12 top-grid Y A 0 0
52 14 HEADER 12 header-grid Y A 0 0
54 14 FOOTER 12 footer-grid Y A 0 0