PHP Table Column Names

Is there a way to display a tables columns,
and then filter out the column names?

SHOW COLUMNS FROM users

But I’d like to somehow filter it with
LIKE ‘custom_%’ – or however that goes, so it only shows Column names that have custom_ as a prefix.

Or should I do this in PHP?

I’ll go through my book again I don’t recall seeing something like this off the top of my head.


SHOW COLUMNS FROM users LIKE 'custom_%'

You can also do something like


SELECT COLUMN_NAME 
  FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'thedatabasename' 
   AND TABLE_NAME = 'users'
  AND (...other filtering clauses...)

Well that was easy lol, thanks a lot :slight_smile: