At 12:29 PM -0500 2/28/05, D. Richard Hipp wrote:
What about the result set
of compound selects or of natural joins where the origin column
is ambiguous?  If knowing the original column is so important,
what do people do with those cases?

Since this was brought up, I'll answer it as a separate thread.

The short answer is that the person writing the SQL needs to do a bit more work, and explicitly define an extra result column whose value differs for each member of the compound query, so one knows which said member the row came from.

For example:

  SELECT 'first' AS member, foo, bar, baz
  FROM table_one
  UNION
  SELECT 'second' AS member, foo, bar, baz
  FROM table_two

As for natural joins ... by definition a natural join combines columns that have the same name and equal values in every row; because of this, it is known that each returned value returns to both source columns.

-- Darren Duncan

Reply via email to