给重复和字段起别名.注意字段名的大小写. . . $result = mysql_query("SELECT a.*,b.ID as ID2,b.Name as Name2,b.Pid as Pid2 FROM tbl_name a,tbl_name b where a.Id=b.Pid and a.Name='aaa'"); while ($res = mysql_fetch_array($result)){ echo $res['id']."<br>"; echo $res['name']."<br>"; echo $res['pid']."<br>"; echo $res['id2']."<br>"; echo $res['name2']."<br>"; echo $res['pid2']."<br><br>"; }
查询完以后我在查询商品时SQL应该怎么写?
.
.
$result = mysql_query("SELECT a.*,b.ID as ID2,b.Name as Name2,b.Pid as Pid2 FROM tbl_name a,tbl_name b where a.Id=b.Pid and a.Name='aaa'");
while ($res = mysql_fetch_array($result)){
echo $res['id']."<br>";
echo $res['name']."<br>";
echo $res['pid']."<br>";
echo $res['id2']."<br>";
echo $res['name2']."<br>";
echo $res['pid2']."<br><br>";
}