select - Selecting fields by ordinal_Number, adapting MS-SQL-Code to MySQL -


i need extract fieldnames great number of tables, having same structure unfortunately not same field names. varying. need check ordinal position of fields required, because tables have same order of fields. newbie on mysql.

my ms-sql-guru gave me 'blueprint' of procedure want via sys.columns, cannot adapt mysql. want have resulting select statement handover next batch of commands.

here have done far:

create definer=`root2`@`%` procedure `sp_getcolsfromschema`(in lsid int) begin set @cols=''; set @tbls = concat('mytableprefix_', lsid);  select      @cols = @cols + column_name + ', '     information_schema.columns     table_name = @tbls collate utf8_unicode_ci         , table_schema = 'myschema'         , ordinal_position in (2 , 4, 5, 7);  set @cols = left(@cols, length(@cols)-1);  set @str = 'select ' + @cols + ' ' + @tbls +';'; prepare stmt @str; execute stmt; end 

when calling procedure error 1064 hint "... check syntax near '0' @ line 1" confusing me.

can please me on right track?


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -