This question already has answers here:
Selecting all columns that start with XXX using a wildcard?

(5个答案)



Equals(=) vs. LIKE

(15个答案)


7年前关闭。




我试图从mysql表中选择所有以pweb开头的列名称,然后使用一个整数。

这适用于所有列名称:
SELECT `COLUMN_NAME`
FROM `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_NAME`='producten';

不幸的是,这行不通,我该如何做到这一点?
SELECT `COLUMN_NAME`
FROM `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_NAME`='producten' AND `COLUMN_NAME` LIKE `pweb`;

谢谢!

最佳答案

试试这个

SELECT `COLUMN_NAME`
FROM `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_NAME`='producten' AND `COLUMN_NAME` LIKE 'pweb%'
AND DATA_TYPE = 'int'

关于mysql - 选择以x开头的列名称,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18377057/

10-11 03:10