2016-08-17 127 views
1

以下查詢在mssql中正常工作。 我試過用information_schema代替sys。但在mysql中沒有運氣。mssql到mysql查詢轉換

  SELECT c.NAME AS property_name, 
        t.NAME AS datatype 
      FROM sys.columns c 
      JOIN sys.objects o 
      ON  o.object_id = c.object_id 
      JOIN sys.types t 
      ON  t.user_type_id = c.user_type_id 
      JOIN sys.schemas s 
      ON  o.schema_id = s.schema_id 
      WHERE s.NAME ='{0}' 
      AND o.NAME ='{1} 

回答

1

在這裏你去:

SELECT 
    COLUMN_NAME AS property_name, 
    DATA_TYPE AS datatype 
FROM information_schema.columns 
WHERE 
    TABLE_SCHEMA = {0} AND 
    TABLE_NAME = {1} 
ORDER BY ORDINAL_POSITION 
+0

感謝很多的幫助。 – user3386325