
//首先配置数据库连接
mysql_connect("localhost","root","");
mysql_select_db("db");
mysql_query("set names 'utf8'");
//写sql语句并执行
$sql="select id from 表名 where 条件";
$query=mysql_query($sql);
$rs=mysql_fetch_array($query);
//打印
echo $rs['id']
以serversql为例:
if exists(select from sysobjects where name='DepartmentTab')
drop table DepartmentTab
create table DepartmentTab--创建一个表
(
DepartID int primary key identity(1,1),--identity自增 ,primary key主键
DepartName nvarchar(50) unique,--unique唯一的,并且不能为空
condition int default('0') --default 默认为0
)
以上就是关于php怎么获取数据库中表的id全部的内容,包括:php怎么获取数据库中表的id、在数据库中表的字段如何创建数据库中唯一的标识id、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)