last day (15 days later) » 

4:16 PM
0
Q: Connect to 2 or more databases and select from tables in those databases in the same host

PedroConnect to 2 or more databases and select from tables in those databases. I never needed this before, but now...i really do need! :) I've googled but i could not find the right answer. I need to connect to 2 or more database and then, if i need to, i want to select info from tables that are in...

 
This may be what you are looking for: http://stackoverflow.com/questions/2132654
 
@Rasclatt thank you for your answer. I've seen that but it only says how to select. What about the connect? is it enough to connect to only one database? Thank you.
 
I think you just use the one connection to access both. As long as the host contains both databases.
 
@Rasclatt not woeking!! it gives me an error "(1142) SELECT command denied to user 'user_name'@'localhost' for table 'table_name'"
 
Are you using shared hosting?
 
4:16 PM
Yes i'm paying one. Is not mine... Is that a problem?
Hi, thank you for interest :)
 
Well if you are using a service like network solutions, when you create a new database it drops it onto open spot on their mysql server so I think they have to be in the same realm. So the one maybe be in mysql08 and the other in mysql03 and I think then they won't work. They would both have to inhabit the same realm.
 
how do i solve that? can i just ask them to solve that? i may try.
 
4:34 PM
Well I am not 100% sure how to do that because every time you create a new database it throws it into a different realm randomly as best I can tell. Anyway, hopefully you can get it to work or you will have to do multiple db connections simultaneously.
 
they are telling me that is the same realm for all database
 
Interesting, well in that case, the other DB may need to have the same login/pass as the one you use for your main DB
 
wait is working...well almost
tell me please how do i get the info is normal as echo $row['info'] or i need to specify each value like SELECT (table_name.field_name.info) AS info_that_i_want ??
 
5:11 PM
@Rasclatt forget it! I solve the problem it was an error, but it was mine! :)
if you can tell me please just one more thing. This works also if i want to INSERT, DELETE, etc. in the other table, right?
 
 
1 hour later…
6:34 PM
I don't see why not. Try it and let me know ! :D
 

  last day (15 days later) »