Skip to content Skip to sidebar Skip to footer

Mysql: Use Value From Another Table As Column Alias?

We have this one table that is really funky and I'm trying to get a descriptive result set out of it. This table stores a tightly-related yet disparate collection of data types, an

Solution 1:

Did you try to wrap aliases into backqoutes?

SELECT 
  data.segment1 AS `type.segment1`,
  data.segment2 AS `type.segment2`,
  data.segment3 AS `type.segment3`
FROM something_obscure AS data
JOIN obscure_type AS type
ON data.obscure_type_id = type.id

Solution 2:

Use single quotes around the aliases

SELECT 
  data.segment1 AS'segment1',
  data.segment2 AS'segment2',
  data.segment3 AS'segment3'FROM something_obscure AS data
JOIN obscure_type AS type
ON data.obscure_type_id = type.id

Working fiddle demo

Other demo with type.*

Post a Comment for "Mysql: Use Value From Another Table As Column Alias?"