List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:November 13 1999 1:13am
Subject:Determination of table and database from field in select...
View as plain text  
>>>>> "Matt" == Matt Greenwood <ljessup@stripped> writes:

Matt> Hi,
Matt> I'm attempting to determine for a given select statement which database
Matt> and table each of the returned fields is associated with.  My reason for
Matt> asking this question is I have written a "select" function in Perl using
Matt> DBI/DBD.  The routine "sub select { ... }" will have no knowledge of the
Matt> select statement until it is sent.

Matt> Therefore simple select statements such as:

Matt> SELECT *
Matt> FROM blarg, foo, bar;

Matt> or

Matt> SELECT *
Matt> FROM foo NATURAL LEFT JOIN bar;

Matt> etc...

Matt> will bring into question which fields belong to which table and
Matt> potentially the associated database.

Matt> Aside from either parsing the select statement myself, or limiting the
Matt> robustness of this routine is there a way to expose this information
Matt> through either DBI or mySQL?

Matt> Thanks,
Matt> Matt

The MySQL C API can be used to get the table name for each column, but 
I don't know if you can get this through DBI/DBD (I scanned through
'perldoc DBI', but couldn't find anything specific);  Maybe someone on
the msql-mysql-modules lists knows something about this...

Regards,
Monty
Thread
Determination of table and database from field in select...Matt Greenwood24 Oct
  • Re: Determination of table and database from field in select...sinisa25 Oct
  • Determination of table and database from field in select...Michael Widenius13 Nov
  • Re: Determination of table and database from field in select...Jochen Wiedmann13 Nov