mysql query “SHOW COLUMNS FROM table like 'colmunname'”:questions

后端 未结 4 756
鱼传尺愫
鱼传尺愫 2021-02-14 14:27

I have a question about SHOW COLUMNS FROM table like \'column name\'\". I have already tried some tests for some times, it seems be similar like \"where colu

4条回答
  •  别那么骄傲
    2021-02-14 14:56

    It's more like

    WHERE column_name LIKE 'column name'
    

    Since it uses LIKE, you can put wildcard patterns in the parameter, e.g.

    SHOW COLUMNS FROM table LIKE '%id'
    

    will find all columns that end in id.

    If there are no wildcard characters, then LIKE is equivalent to =.

    If you don't want to use LIKE, you can use WHERE:

    SHOW COLUMNS FROM table WHERE field = 'column name';
    

    In the SHOW COLUMNS output, the field column contains the column names. The WHERE clause also permits testing other attributes, e.g.

    SHOW COLUMNS FROM table WHERE type LIKE 'varchar%'
    

    will find all VARCHAR columns.

提交回复
热议问题