Gossamer Forum
Home : General : Perl Programming :

SQL Search

Quote Reply
SQL Search
IS there a way I can search 2 databases at the same time in mysql?
Both have tha same fields and are exactly the same, but with different data...

Thanks

Thiago Moretti
http://www.buscabr.com
Quote Reply
Re: SQL Search In reply to
Assuming that both databases are in the same database and are 2 seperate tables and not databases then you could do the following in your select statement:

SELECT name, description, location, url, content_type FROM table1, table2

If your databases are actually two seperate databases and not two seperate tables in one database, then I have no idea if that is possible.

If there not in the same database and two seperate tables, then perhaps what you could do is to do a mysqldump and dump the 2nd database to a text file then go in and edit the txt file to make sure that the tables are not named the same as whats in database 1, and then import the new table into database 1, so that you have the info stored within the same database but different tables, then you can easily select from both tables within the same database. Of course if this is a dynamic type thing and people are entering info into both databases, then your scripts would have to be rewritten to write to database1 table whatever instead of database2.

I hope I havn't made this more confusing..... I have recently done this when we had two seperate databases but found down the road that we needed to search both at the same time, so I created a new table, in the first database and imported my data, then rewrote my scripts to output to the new table in the database1 so that I could search both "databases" when they were in one database but two seperate tables.
Harrison



"I've got if's pretty good, but that's about it"
Quote Reply
Re: SQL Search In reply to
thank you..

you didnt made it more confusig, you have really clarified things to me.. i have both tables in the same database, and this search worked.

thanks a lot

Thiago Moretti
http://www.buscabr.com