Title: wpdb::get_col_info
Published: April 25, 2014
Last modified: February 24, 2026

---

# wpdb::get_col_info( string $info_type, int $col_offset = -1 ): mixed

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wpdb/get_col_info/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wpdb/get_col_info/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wpdb/get_col_info/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wpdb/get_col_info/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wpdb/get_col_info/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wpdb/get_col_info/?output_format=md#wp--skip-link--target)

Retrieves column metadata from the last query.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wpdb/get_col_info/?output_format=md#parameters)󠁿

 `$info_type`stringoptional

Possible values include `'name'`, `'table'`, `'def'`, `'max_length'`, `'not_null'`,`'
primary_key'`, `'multiple_key'`, `'unique_key'`, `'numeric'`, `'blob'`, `'type'`,`'
unsigned'`, `'zerofill'`. Default `'name'`.

`$col_offset`intoptional

0: col name. 1: which table the col’s in. 2: col’s max length.
 3: if the col is
numeric. 4: col’s type.

Default:`-1`

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wpdb/get_col_info/?output_format=md#return)󠁿

 mixed Column results.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wpdb/get_col_info/?output_format=md#source)󠁿

    ```php
    public function get_col_info( $info_type = 'name', $col_offset = -1 ) {
    	$this->load_col_info();

    	if ( $this->col_info ) {
    		if ( -1 === $col_offset ) {
    			$i         = 0;
    			$new_array = array();
    			foreach ( (array) $this->col_info as $col ) {
    				$new_array[ $i ] = $col->{$info_type};
    				++$i;
    			}
    			return $new_array;
    		} else {
    			return $this->col_info[ $col_offset ]->{$info_type};
    		}
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wpdb.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wpdb.php#L3895)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wpdb.php#L3895-L3911)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wpdb/get_col_info/?output_format=md#related)󠁿

| Uses | Description | 
| [wpdb::load_col_info()](https://developer.wordpress.org/reference/classes/wpdb/load_col_info/)`wp-includes/class-wpdb.php` |

Loads the column metadata from the last query.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wpdb/get_col_info/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.71](https://developer.wordpress.org/reference/since/0.71/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwpdb%2Fget_col_info%2F)
before being able to contribute a note or feedback.