2

Using sqlworkBench I'm looking for column names. I'd like to use wild cards in my search using the below query. when I search for column "activated_at" it works but searching with wild card fails, can anyone help ?

SELECT 
    table_schema,
    table_name, 
    column_name, 
    data_type,
    ordinal_position

FROM  INFORMATION_SCHEMA.COLUMNS 

WHERE column_name = 'activated_a*' ; 

2 Answers 2

5

You can try this:

SELECT table_schema, table_name, column_name, data_type, ordinal_position
FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name LIKE 'activated_a%' ;

When you want to use wildcard, you have to use LIKE instead of '='

4

You need to use LIKE instead of =.

So, something like this:

SELECT table_schema, table_name, column_name, data_type, ordinal_position
FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name LIKE 'activated_a%' ; 

% is the wildcard character used by MySQL. See the MySQL documentation for string comparisons for further details.

Not the answer you're looking for? Browse other questions tagged or ask your own question.