First, the describe command is used to view detailed design information of a specific table

For example, to view the design information of the guestbook table,Available:

describe guestbook
describe ol_user userid

Second, you can use "show comnus" to view the column names of the tables in the database

There are two ways to use it:

show columns form table name from database name


show columns from database name.Table Name

Third, use the describe command to query specific column information

describe guestbook id

Is to query the column information of the id field in the guestbook

{describe | desc} tbl_name [col_name | wild]

describe is short for show columns from.

describe Provides column information about a table.col_name can be a column name or a string containing the sql wildcard characters "%" and "_".There is no need to surround the string with quotes.

mysql>desc ol_user username \ g
*************************** 1. row ******************** *******
  type:varchar (100)
1 row in set (0.02 sec)

Fourth, determine whether the field exists

mysql_connect ("localhost", "root", "root");
mysql_select_db ("demo");
$test=mysql_query ("describe cdb_posts first");
$test=mysql_fetch_array ($test);

$test [0] returns the name of the field,For example, if I want to query the first field, the return is first

If this field does not exist, it will return null, which can be used to determine whether a field exists.