用mysql建一张名为Employee的表,ID、NAME、DISPLAY_NAME
并拿一个字段为例,写好增、删、改、查的语句,谢谢
并拿一个字段为例,写好增、删、改、查的语句,谢谢
答案:CREATE TABLE `Employee` ( `ID` int( 10 ) unsigned NOT NULL auto_increment ,
`NAME` varchar( 32 ) NOT NULL ,
`DISPLAY_NAME` varchar( 32 ) NOT NULL ,
PRIMARY KEY ( `ID` ) )
//add
$name=$_POST['name'];
$displayname=$_POST['displayname'];
mysql_query("INSERT INTO Employee SET NAME='$name',DISPLAY_NAME='$displayname'");
//remove
$id=intval($_REQUEST['ID']);
mysql_query("DELETE FROM Employee WHERE ID='$id'");
//UPDATE
mysql_query("UPDATE Employee SET NAME='$name',DISPLAY_NAME='$displayname' WHERE ID='$id'");
//select
$res=mysql_query("select 8 from Employee");
while($row=mysql_fetch_array($res))
{
echo "ID=".$row['ID']." NAME=".$row['NAME']." DISPLAY=".$row['DISPLAY_NAME']."<br>";
}
上一个:mysql创建数据库问题!
下一个:mysql和sql server 2005二个数据库都一样的吗?里面语句、代码都一样的吗?