![]() ![]() Without formally scripting a Stored Procedure, this is as good as it is going to get. ![]() The SELECT will let you see the generated SQL ![]() WHERE table_schema=DATABASE() AND table_name='foo' AND column_name IN This function is used to concat multiple columns or strings into a single one. Here is the Dynamic SQL to generate the same query USE mydbĬONCAT('SELECT ',column_name,' AS name FROM ',table_name) For this example, let's suppose the following If the intent is to select some columns and generate a single column list of the distinct values, then Dynamic SQL is needed to produce such a query. This would produce a distinct list of names. Nothing could be more elegant that using UNION SELECT her_name AS name FROM foo In this instance, what makes UNION an absolute must is the merging of three columns into a single column.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |