0

I have 2 databases on a server:

  • database1
  • database2

I am trying to query a table in each database. However, when I try that, I get the following error:

Unknown table 'database2.client' in field list

Here is the code that I am using in a script running on database 1:

SELECT database2.client.id;

It returns the unknown table error. The odd thing is that if I query for the databases, it shows them both:

SHOW DATABASES

it returns the following:

information_schema
database1
database2

I'm not sure why the SHOW syntax confirms that both databases are there, but I'm not able to select data from the other table.

Daniel C
  • 607
  • 2
  • 8
  • 20

3 Answers3

1

Can you select it if you first run use database2, and then SELECT client.id?

EDIT:

As many people have pointed out, you need to use the correct SELECT syntax.

USE database2;
SELECT id FROM client;
gcochard
  • 11,408
  • 1
  • 26
  • 41
1

Try this:

SELECT id FROM database2.client;
JSK NS
  • 3,346
  • 2
  • 25
  • 42
1

I believe the correct syntax would be:

SELECT id FROM database2.client

Where id is the column, database2 is your database, and client is your table.

Kermit
  • 33,827
  • 13
  • 85
  • 121