php - Connect multiple tables in different databases? MySql -
Hey, I have a good way of using at least 2 database php in mysql and collecting information within each Looking to connect to the tables they database from
The tables will be related information such as I have site names in a database ('SiteInfo') in a table called 'database'. I also have a site description in another database ('sitedescriptions') in a table named 'Description'.
I can not get these two databases to talk to each other. Does anyone know how I can go about doing the above work? I am very new to php / mysql.
In addition, there are three lines of information related to a site in the table of the site in the 'Description' table
Thanks for any help.
A good strategy for you may be to define a single MySQL user, whose database Have similar access to something like this:
Allow everyone on sitino * 'Password' identified on user @ localhost; To authorize the 'password' user @ local host; Flush Pvt .;
Once you have a connection that is established as a user, then you will have access to both databases, and they are easily referenced by putting their table names with the database name can do.
SELECT * from siteinfo.sites;
If you can not join your tables in the database with any difficulty in this way, to answer your second question, to get all three description lines for a site, then You can do this (assuming the sites have the same ID in each database, or the same name, or something unique that you can join on):
select * siteinfo. Join the site d as Left sitedescriptions.description as s.siteId = ds IteId ou s.siteId = 123;
Comments
Post a Comment