选择icon_ * FROM
images
WHERE 1
我有三个字段,icon_small
,icon_big
和icon_large
。如何在不手动指定它们的情况下获得全部三项?
选择icon_ * FROM
images
WHERE 1
我有三个字段,icon_small
,icon_big
和icon_large
。如何在不手动指定它们的情况下获得全部三项?
据我所知,你不能。您将不得不手动指定它们。
(见式两份)
您的SELECT
指定他们,但你可以通过做选择的列清单(然后只能在dynamic SQL使用):
select column_name from information_schema.columns
where table_schema = database()
and table_name = 'mytesttable'
and column_name like 'icon_%'
set @qry = (select concat('select ',group_concat(column_name), ' from ' ,table_name) from
information_schema.columns
where table_schema = database()
and table_name = 'your_table_name'
and column_name like 'icon_%');
prepare stmt from @qry;
execute stmt;
deallocate prepare stmt;