Claus Svalekjær :
I try to perform this SQL on a MYSQL 8.0.18 server:
SELECT `information_schema`.* FROM `information_schema`.`TABLES` WHERE `information_schema`.`TABLE_SCHEMA` = 'DB_NAME' ORDER BY `information_schema`.`TABLE_SCHEMA` LIMIT 0, 25
but get this error:
#1051 - Unknown table 'information_schema'
Which should be there hence it is a standard MySQL database, it works IF I remove information_schema
from the SQL and select the database 'information_schema'.
My problem is I just wish to connect and then perform the SQL to retrieve table for a specific database.
Simon Brahan :
Your query is referring to information_shcema
as a table, rather than a database. The table information_schema
doesn't exist. You want something like:
SELECT * FROM `information_schema`.`TABLES`
WHERE `TABLES`.`TABLE_SCHEMA` = 'DB_NAME'
ORDER BY `TABLES`.`TABLE_SCHEMA`
LIMIT 0, 25
Note I've removed information_schema
from the WHERE
and ORDER BY
clause.
Your ORDER BY
is ordering by the same field you're filtering by, so will have no effect.
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=360249&siteId=1