我试图从以pweb开头的mysql表中选择所有列名,然后有一个整数。
这适用于所有列名:
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`;
谢谢!
答案 0 :(得分:6)
试试这个
SELECT `COLUMN_NAME`
FROM `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_NAME`='producten' AND `COLUMN_NAME` LIKE 'pweb%'
AND DATA_TYPE = 'int'
答案 1 :(得分:2)
你必须在pweb之后添加%。
所以sql语句选择以pweb * *
开头的所有column_name注意: * *表示其他caracteres
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA, COLUMNS
WHERE TABLE_NAME='producten' AND COLUMN_NAME LIKE 'pweb%';
希望这能帮到你
答案 2 :(得分:1)
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME='producten'
AND COLUMN_NAME LIKE 'pweb%'
AND DATA_TYPE = 'int'