$sql="select * from xsktdl where text1 like '%$gjc%' union all select * from xsktdl2 where text1 like '%$gjc%'";
$sql="select * from (select * from xsktdl union all select * from xsktdl2) where text1 like '%$gjc%'";
2种方式都不行 查询结果是无记录
$sql="select * from (select * from xsktdl union all select * from xsktdl2) where text1 like '%$gjc%'";
2种方式都不行 查询结果是无记录
$sql="select * from xsktdl where text1 like '%$gjc%'";
这是1个表的写法 怎么写上2个表的
$title=htmlspecialchars($_POST["gjc"]);
$resultt=mysql_query("select * from xsktdl where text1 like '%$title%' union all select * from xsktdl2 where text1 like '%$title%'");
$i=9;
$j=0;
while($rowww=mysql_fetch_array($resultt))
{
$j++;
?> <?=$rowww["text1"]?><br><?php
if($j==$i)
{
$j=0;
echo "</tr>";
echo "<tr>";
}
}
for($k=$i-$j;$k>0;$k--)
{
echo "<td></td>";
}
?>
select * from table_a, table_b where 1 and table_a.field1 = table_b.filed1
形式是这样,希望能理解
如果这样可以,说明xsktdl与xsktd2的字段数不同。
所以你需要在select时选择共同的字段,否则会出错。