SELECT foreign_db.ername, firstname, lastname from foreign_db.login, user where For what it's worth, (2) doesn't work for me.Īfter reading your clarification, I am under the impression that you actually want to query tables residing in two separate MySQL server instances. NOT just make different queries to different DBs. I want a solution that allows me to do something like SELECT foreign_db.ername, firstname, lastname from foreign_db.login, user where. Instead, they allow me to access two different DBs separately. Is there something better than this? Is there a way for me to do a cross db MySQL query in PHP without having to something crazy like (2)?ĬLARIFICATION: None of the proposed answers actually let me do a cross db query. This also makes sad since I don't want to go through all my code and prepend a db name to every query. This makes sense since I haven't used mysql_select_db to tell PHP what db I want to access. From some of the examples I've seen, this seems to mean that I have to specify the db for every query that I make. This is our current setup and putting a database as a namespace identifier doesn't seem to work (it works fine in the MySQL shell so I know it's not a problem with our MySQL server setup).ĭon't use mysql_select_db. Use mysql_select_db but be stuck with only using one db at a time. This seems to imply that if I want to use MySQL with PHP, I have a couple of choices: I took a look at mysql_select_db for PHP. This worked great but when our hero tried to use this newfound knowledge in PHP he found his best friend FAIL waiting for him. In our last episode ( How I constructed a cross database query in MySQL) I learned how to construct a cross database query in MySQL.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |