我正在尝试将以下SQL Server代码转换为MySql ...
SELECT
columns = COALESCE(columns + ',', '') + Cast(sc.name AS char(64))
FROM
sysColumns sc
INNER JOIN
sysObjects so ON sc.ID = so.ID
WHERE
so.type = 'u'; AND
so.name = tableName;
此转换是否有任何工具或参考链接?
我发现我可以all_source
使用sysObjects
,但不确定sysColumns
和tableName
的用途。
有什么建议吗?
答案 0 :(得分:0)
MySQL 5.5.30架构设置:
CREATE TABLE IF NOT EXISTS `category` (
`id` int(11) NOT NULL,
`parent_id` int(11) NOT NULL,
`label` varchar(20) NOT NULL,
`level` int(11) NOT NULL,
`path` varchar(100) NOT NULL,
`sortorder` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
查询1 :
SELECT t.table_name,
group_concat( c.column_name ORDER BY c.ordinal_position ) AS columns
FROM information_schema.tables t
JOIN information_schema.columns c ON t.table_name = c.table_name
WHERE t.table_name = 'category'
GROUP BY t.table_name
<强> Results 强>:
| TABLE_NAME | COLUMNS |
--------------------------------------------------------
| category | id,parent_id,label,level,path,sortorder |