mysql_field_database()?
am 28.01.2008 08:56:37 von Mango
I'm working with queries that involve more than one database and am
trying to figure out a way to determine which database a particular
field came from. I've used mysql_field_name and mysql_field_table for
field & table names but there does not seem to be a
mysql_field_database() function.
Any pointers on writing one? :)
-Mango
Re: mysql_field_database()?
am 28.01.2008 10:55:31 von Erwin Moller
Mango wrote:
> I'm working with queries that involve more than one database and am
> trying to figure out a way to determine which database a particular
> field came from. I've used mysql_field_name and mysql_field_table for
> field & table names but there does not seem to be a
> mysql_field_database() function.
>
> Any pointers on writing one? :)
>
> -Mango
Hi,
I have no clue, but I am suprised you cannot tell where which data came
from.
You must be using multiple connections to different databases, so you
should know what field you retrieve from where.
Or do I miss something?
Erwin Moller
Re: mysql_field_database()?
am 28.01.2008 14:25:34 von Captain Paralytic
On 28 Jan, 09:55, Erwin Moller
wrote:
> Mango wrote:
> > I'm working with queries that involve more than one database and am
> > trying to figure out a way to determine which database a particular
> > field came from. I've used mysql_field_name and mysql_field_table for
> > field & table names but there does not seem to be a
> > mysql_field_database() function.
>
> > Any pointers on writing one? :)
>
> > -Mango
>
> Hi,
>
> I have no clue, but I am suprised you cannot tell where which data came
> from.
> You must be using multiple connections to different databases, so you
> should know what field you retrieve from where.
>
> Or do I miss something?
>
> Erwin Moller
Suppose he is querying:
SELECT
*
FROM db1.table
JOIN db2.table USING(id)
Re: mysql_field_database()?
am 28.01.2008 14:34:54 von usenet
In article <479da6c1$0$85784$e4fe514c@news.xs4all.nl>, Erwin Moller wrote:
> I have no clue, but I am suprised you cannot tell where which data came
> from.
>
> Or do I miss something?
I think so.
I suspect he wants to know "automatically" where which field came from.
That's really part of the underlying assumptions of SQL, you don't and,
automatically, can't.
You'll have to keep track of it yourself in code.
Have fun
Mark
Re: mysql_field_database()?
am 28.01.2008 18:33:09 von Mango
Captain Paralytic wrote:
>
> Suppose he is querying:
> SELECT
> *
> FROM db1.table
> JOIN db2.table USING(id)
That is exactly the kind of situation I am anticipating. If anyone has
any suggestions, that would be great.
-Mango
Re: mysql_field_database()?
am 29.01.2008 09:37:53 von Erwin Moller
Mango wrote:
> Captain Paralytic wrote:
>>
>> Suppose he is querying:
>> SELECT
>> *
>> FROM db1.table
>> JOIN db2.table USING(id)
>
> That is exactly the kind of situation I am anticipating. If anyone has
> any suggestions, that would be great.
>
> -Mango
Hi Mango,
Well, in that case, you can simply mark your columns.
And don't use * to select columns.
Like this:
SELECT
db1.userid as db1_userid,
db1.name as db1_name,
db2.userid as db2_userid,
db2.city as db2_city
FROM db1.tbluser
JOIN db2.tblcity etc etc.
Regards,
Erwin Moller
Re: mysql_field_database()?
am 29.01.2008 17:41:49 von Mango
Thanks a lot!
Mango :)
Erwin Moller wrote:
> Hi Mango,
>
> Well, in that case, you can simply mark your columns.
> And don't use * to select columns.
>
> Like this:
> SELECT
> db1.userid as db1_userid,
> db1.name as db1_name,
> db2.userid as db2_userid,
> db2.city as db2_city
> FROM db1.tbluser
> JOIN db2.tblcity etc etc.
>
> Regards,
> Erwin Moller