Connect multiple tables in different databases? MySql

前端 未结 2 1028
臣服心动
臣服心动 2021-01-15 06:33

Hey, I am looking for a good way to connect to at least 2 databases in mysql using php and gathering information within each of those databases from tables.

The tabl

2条回答
  •  余生分开走
    2021-01-15 07:18

    I always use the full name for my tables. So if a table named tablea is in a database called dba, I would do the following query:

    SELECT * FROM dba.tablea
    

    This allows you to switch databases really easily. If you don't want to remember to do this, I also suggest defining constants for each of your tables, at which time you can put it in.

提交回复
热议问题