Can you tell me what's wrong with this MySQL function?
I followed the link How can I “select *” from a table in MySQL but omit certain columns? to define a function in MySQL. But I got an error "no database selected".
DELIMITER $$
CREATE FUNCTION getTableColumns(_schemaName varchar(100), _tableName varchar(100), _omitColumns varchar(200)) RETURNS varchar(5000)
BEGIN
SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), '_omitColumns,', '')
FROM information_schema.columns
WHERE table_schema = _schemaName AND table_name = _tableName
INTO results;
RETURN results;
END$$
Error Code: 1046. No database selected Select the default DB to be used by double-clicking its name in the SCHEMAS list in the sidebar.
只需添加数据库名称和函数名称
your_database_name.getTableColumns(......
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.