Jump to content


Photo

Select the same field form 3 Databases


  • Please log in to reply
4 replies to this topic

#1 neugi

neugi
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 13 September 2006 - 03:01 PM

Hi,

i've got 3 Databases with adresses.
From this 3 Database want to select from the table adresse the field name.

is there a way to select the 3 name fields into one.

what i would like to get is not:
name (table1) | name (table2) | name (table3)

i would like to get only:
name (table1/table2/table3)

i tried to use this query but it don't work:

SELECT NAME1
FROM liezen.ADRESSEN cl, kirchdorf.ADRESSEN ck, gmunden.ADRESSEN cg

thx

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 13 September 2006 - 03:21 PM

You'll need to be connected to all 3 databases via the same connection, which is only possible if they're on the same box and have the same login credentials, AFAIK.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 neugi

neugi
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 13 September 2006 - 03:28 PM

can you give me an example?

thx

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 13 September 2006 - 04:41 PM

There's no example to give... if they're all on the same server, and the user/pass are the same, you should be able to run the statement you indicated.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 Zane

Zane
  • Administrators
  • Advanced Member
  • 4,135 posts

Posted 14 September 2006 - 05:02 AM

is there a way to select the 3 name fields into one.

do you mean concatenating them into one field

if that's the case you can do this
SELECT CONCAT(liezen.ADRESSEN, kirchdorf.ADRESSEN, gmunden.ADRESSEN) as allNames

Note*
they won't be separated by any spaces with that code
you'd have to include the spaces for that
like

CONCAT(gmunden.ADRESSEN, ' ', liezen.ADRESSEN)


btn_donate_SM.gif Want to thank me? Contribute to my PayPal piggy-bank
 

172938.png




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users