what i need is to be albe to select all the fields information from a table, where the name of the field from another table called "field_(and a number)"
i've tryed things like that but it didn't work...
SELECT *
FROM `fieldList`
WHERE ID = "(SUBSTRING(SHOW FIELDS,5) FROM formList_5 LIKE 'field_%')"
and
SELECT *
FROM `fieldList`
WHERE ID = "SUBSTRING((SHOW FIELDS FROM formList_5 LIKE 'field_%'),5)"
but it didn't work.
This is what you need:
SELECT *
FROM `fieldlist`
WHERE id IN (SELECT SUBSTRING(column_name, 5)
FROM information_schema.columns
WHERE table_name = 'formList_5'
AND column_name LIKE 'field_%')
But, for sanity's sake, review your DB design if you can.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.