Re: JOIN across db's in MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks, I found the post from John Holmes and was able to reconstruct the
query in mysql.  But when I transferred that over to php and try to extract
an associative array from each record, I found that only one column came out
instead of two.

By simply changing the query from:
    $query = "select t1.name, t2.name from test1.table1 t1 join test2.table2
t2 on t1.id = t2.id";
to:
    $query = "select t1.name as first, t2.name as last from test1.table1 t1
join test2.table2 t2 on t1.id = t2.id";
the associative array worked as desired.

I suspect what was happening originally was both columns when extracted from
the result and placed into the array were both stored under the index
"name".  By changing them to have unique field names "as first" and "as
last" allowed two different indexes.  Perhaps there is a way of extracting
data from the query result that will allow redundant names, but I don't know
what that is.


thanks for the help,
Mike


Jeffrey N Dyke <jeffrey_n_Dyke@Keane.com> wrote in message
OFE374747F.324B9B13-ON85256DA5.0052CA22@keane.com">news:OFE374747F.324B9B13-ON85256DA5.0052CA22@keane.com...
>
> i asked this same question once and somehwere in the archives is a post by
> John Holmes that shows an example of how mysql allows db joins.  its from
> last month i believe....
>
> http://marc.theaimsgroup.com/?l=php-db
>
> but in short, mysql does support this using ..... db.table.field
>
> hth
> Jeff
>
>
>
>                       "Mike Tallroth"
>                       <mike.tallroth@pl        To:
php-db@lists.php.net
>                       exus.com>                cc:
>                                                Subject:   JOIN
across db's in MySQL
>                       09/18/2003 10:47
>                       AM
>
>
>
>
>
>
> In the big scheme of things, I need several functions to be performed by a
> web interface / database system.  In an attempt to maintain some sense of
> order, I'm hoping to divide common data into a seperate MySQL database
away
> from the function specific data.  For example, I need to do project
> allocation and vendor quality tracking.  These functions are generally
> unrelated but call on similar data (people in the group).
>
> My plan was to create a MySQL database called "admin" which contained
> people, customers, locations, addresses, etc, and seperate databases for
> each of the other functions projectallocation, vendorquality, etc.
>
> The problem I'm seeing is that there is no clean way of creating queries
> across database boundaries.  Does PHP support this and I'm not seeing it?
> Does anyone know of third party code that accomplishes this "manually"?
Am
> I out in left field on my desire to setup the database structure this way?
>
> thanks,
>
> --
> Mike Tallroth
> Engineering Supervisor
> Test DesignCenter
> Plexus Technology Group
> Neenah, WI
> mike.tallroth @plexus.com
> 920-751-5418
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux