PHP查询MYSQL表的主键

Posted ylong52

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP查询MYSQL表的主键相关的知识,希望对你有一定的参考价值。

$sql = "SELECT * from Person";
$result = mysql_query($sql,$con);

while ($property = mysql_fetch_field($result))
  {
  echo "Field name: " . $property->name . "<br />";
  echo "Table name: " . $property->table . "<br />";
  echo "Default value: " . $property->def . "<br />";
  echo "Max length: " . $property->max_length . "<br />";
  echo "Not NULL: " . $property->not_null . "<br />"; 
  echo "Primary Key: " . $property->primary_key . "<br />";
  echo "Unique Key: " . $property->unique_key . "<br />"; 
  echo "Mutliple Key: " . $property->multiple_key . "<br />";
  echo "Numeric Field: " . $property->numeric . "<br />";
  echo "BLOB: " . $property->blob . "<br />";
  echo "Field Type: " . $property->type . "<br />";
  echo "Unsigned: " . $property->unsigned . "<br />";
  echo "Zero-filled: " . $property->zerofill . "<br /><br />"; 
  }

 

关键字段:
echo "Primary Key: " . $property->primary_key . "<br />";

以上是关于PHP查询MYSQL表的主键的主要内容,如果未能解决你的问题,请参考以下文章

SQL查询查找表的主键?

MySql在一个查询中获取逗号分隔的主键

MySQL多表查询

Mysql主键事务以及高级查询

oracle怎么查询所有的表有没有主键

在线等!!如何通过主表及其主键查询到与之关联的表及关联字段?数据库为db2