Selecting all columns that start with XXX using a wildcard?

You’d have to build the SQL dynamically. As a starting point, this would get you the column names you’re seeking.

SELECT COLUMN_NAME
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE table_name="Foods"
        AND table_schema="YourDB"
        AND column_name LIKE 'Vegetable%'

Leave a Comment