mysqL两个表连接查询,把结果存放到一个数组(PHP)
发布网友
发布时间:2022-04-10 02:59
我来回答
共2个回答
热心网友
时间:2022-04-10 04:29
<?php
$sql = "select a.A, a.B, a.C, a.D, b.E, b.F, b.G from Table1 a left join Table2 b on a.C = b.C";
$Conn = mysql_connect("localhost", "root","");
mysql_select_db("Table1",$Conn);
$RS = mysql_query($sql,$Conn);
//把结果集$RS第一行读入数组$rs
$rs = mysql_fetch_array($RS,MYSQL_ASSOC);
mysql_free_result($RS);
mysql_close($Conn);
print "<pre>";
print_r($rs);
print "</pre>";
echo $rs["A"];
echo $rs["G"];
?>
热心网友
时间:2022-04-10 05:47
没搞明白你想干啥
给你写出来俩吧
select * from 表一 union select * from 表二
select * from 表一,表二 where 表一.c=表二.c