MySQL SHOW COLUMNS的退货顺序 [英] Return order of MySQL SHOW COLUMNS

查看:107
本文介绍了MySQL SHOW COLUMNS的退货顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到特定表中的列,这没问题:

I need to find the columns in a specific table, which is no problem:

SHOW COLUMNS FROM tablename LIKE '%ColumnPrefix%';

但是我需要知道它们将以什么顺序返回,最好选择按字母顺序升序排列结果.我没有使用ORDER BY的运气.

But I need to know what order they will be returned, preferably by choosing to order the results ascending alphabetically. I have had no luck with using ORDER BY.

有什么想法吗?

推荐答案

您可以查询表

You can query the table INFORMATION_SCHEMA.COLUMNS to get the information that SHOW COLUMNS gives you, plus it allows you to use ORDER BY or any other SQL syntax you might want to use:

SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'tablename'
  AND column_name LIKE 'ColumnPrefix%'
ORDER BY column_name

这篇关于MySQL SHOW COLUMNS的退货顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆