简体   繁体   中英

specifying database on select statement is not working in MySQL View

 SELECT `db_name`.`view_name` . *
 FROM `db_name`.`view_name`

Above query statement for View is not working. Below error occurred.

#1051 - Unknown table 'view_name' 

Below query statements for Table is working. (same)

 SELECT `db_name`.`table_name` . *
 FROM `db_name`.`table_name`

 SELECT *
 FROM `db_name`.`view_name`

I don't know why this work. Could you tell me why this happened? (or some link)

Thank you.

MySQL version is 5.1.73.

Try this:
SELECT * FROM `db_name`.`table_name`;
You don't need to put DB and Table name after the SELECT. You could do something like this to select particular column:
SELECT `column1`,`column2` FROM `db_name`.`table_name`

Hope you missed the schemaname in the select statement

So your query will be

SELECT `dbname`.`schemaname`.`tablename`.*
FROM `dbname`.`schemaname`.`tablename`

or simply * in the SELECT as

SELECT *
FROM `dbname`.`schemaname`.`tablename`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM