mysql创建临时表的方法并不复杂,下面就为您详细介绍php mysql创建临时表的实现方法,希望对您学习mysql创建临时表方面能有所帮助。
- <?php
- $link=mysql_connect('localhost','root','456789');
- if($link){
- mysql_select_db('cppc360',$link);
- mysql_query("set names 'gbk'");
- echo "数据库连接已经成功!";
- }
- $temp_sql = "create temporary table tmp_query (tmp_id int(11) NOT NULL auto_increment PRIMARY KEY,id int(11) default NULL,area varchar(20) default NULL)";
- $temp_query = mysql_query($temp_sql);
- $sql="insert into tmp_query(id,area) select id,area from php168_item_content_1 where content like '%电厂%' order by id desc";
- mysql_query($sql);
- $sql="select * from tmp_query";
- $query1=mysql_query($sql);
- echo mysql_num_rows($query1);
- while($rs=mysql_fetch_array($query1)){
- echo $rs[id]." ".$rs[area]."<br>";
- }
- ?>
【编辑推荐】