Home  >  Article  >  Database  >  How to determine whether a mysql field exists

How to determine whether a mysql field exists

WBOY
WBOYOriginal
2022-02-15 10:33:018361browse

Method: 1. Use the desc command, the syntax is "desc table name field"; 2. Use the "show columns" command, the syntax is "show columns from table name like field"; 3. Use the describe command, The syntax is "describe table name field".

How to determine whether a mysql field exists

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How to determine whether a mysql field exists

1. desc command

Format: desc tablename columnname

Example:

desc `table` `mid`
desc `table` '%abc%'

2. show columns command

Format: show columns from tablename like columnname

Example:

show columns from `table` like 'mid'
show columns from `table` like '%abc%'

3. describe command

Format: describe tablename columnname

describe is equivalent to show columns from

Example:

describe `table` `mid`
describe `table` '%abc%'

Recommended learning:mysql video tutorial

The above is the detailed content of How to determine whether a mysql field exists. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn