SELECT b.dbId AS `brand`, b.shortName AS `brand-short`, p.dbId AS `phone` FROM brands AS b LEFT JOIN phones AS p ON p.brands = b.dbId WHERE CONCAT( b.shortName, '-', p.shortName ) = TRIM( 'apple-iphone-4s-64gb-(atandt)' );