Skip to main content

Posts

Showing posts from March, 2010

One more SQL hack (or How I Married a Genius)

Here's my problem.  I'm making the following SQL call from my application: select a.*, b.* from foo a, bar b where a.[column] = b.[column] I don't know on the application end what fields are in what table, and I don't know what field the join will be on -- that's all dynamic. I need to know from looking at my result set which table each column came from.  The problem of course is that I can't (at least in mysql) because if you run a select with a *, you only get back column names as a headers. After beating my head against it, and not coming up with a solution, I IMed my big brain DB team, Greg and Ellie, but they were both apparently at lunch.  Then I remembered at my new job we have a $50k/yr contract with MySQL for support, so I called them. It took quite a while to explain to the 1st level of customer support what the problem was.  He kept insisting the answer was to use an "as", but I tried that long before I called, and it doesn't w...