0
I have the following query in SQL Server:
Declare @val Varchar(max)
Select @val = COALESCE(@val + ', ' + col.name, col.name)
FROM sys.objects AS obj
INNER JOIN sys.columns AS col ON col.object_id = obj.object_id
INNER JOIN sys.index_columns AS idx_cols ON idx_cols.column_id = col.column_id
AND idx_cols.object_id = col.object_id
INNER JOIN sys.indexes AS idx ON idx_cols.index_id = idx.index_id AND idx.object_id = col.object_id
WHERE (obj.name = 'NOME_TABELA' ) AND (idx.is_unique = 1)
if @val is null
Select @val = COALESCE(@val + ', ' + COLUMN_NAME, COLUMN_NAME)
from information_schema.columns
where table_name = 'NOME_TABELA'
order by ORDINAL_POSITION
Select @val varColumnsOrder
Some fields do not exist in Mysql (like id
of some tables sys.objects
), how would you transform this first function into Mysql?
Since the first function the relevance is to seek by following the id
.