MySQL三表查询

MySQL三表查询,第1张

select *

from travelerinfo t1 left join tickorderinfo t2 on t1.orderId=t2.orderId

                                 left join pnrauth t3 on t2.tickOrderId=t3.tickOrderId

where t2.status=28 and t3.authPCC='ABC'

order by t1.orderid

limit 1000

INSERT INTO ticketrefauth (orderId,pnrCode,infoSource,ticketRef) )

SELECT t1.orderId,t1.pnrCode,t1.ticketRef,t4.infoSource

为什么2个括号,,,

INSERT INTO ticketrefauth (orderId,pnrCode,infoSource,ticketRef)

SELECT t1.orderId,t1.pnrCode,t1.ticketRef,t4.infoSource

这样

这个要用到ajax 的。还要访问数据库。我给你贴上代码

<select name="pro" onchange="showProvince(this.value)">

<option value="0" selected="selected">sheng</option>

<?php

$con = @mysql_connect("localhost","root","")

if (!$con)

{

die('Could not connect: ' . mysql_error())

}

mysql_select_db("test", $con)

$sql = "SELECT * FROM pro"

$query = mysql_query($sql)

while($row = mysql_fetch_array($query)){

?>

<option value="<?php echo $row['pid']?>" ><?php echo $row['pname']?></option>

<?php }

mysql_close($con)

?>

</select>

<select name="city" class="city" onchange="showCity(this.value)" >

<option value="0" selected="selected">shi</option>

</select>

<select name="shi" class="xian" >

<option value="0" selected="selected">xian</option>

</select>

下面是ajax代码:

function showProvince($pid){

$.post("city.php",{pid:$pid},

function(data){

$(".city").html(data)

})

}

function showCity(cid){

$.post("shi.php",{cid:cid},

function(data){

$(".xian").html(data)

})

}

下面是两个php文件。主要是查询数据库的:

<?php

$con = @mysql_connect("localhost","root","")

if (!$con)

{

die('Could not connect: ' . mysql_error())

}

mysql_select_db("test", $con)

$cid = $_POST['cid']

$sql = "SELECT * FROM shi where cid = $cid"

$query = mysql_query($sql)

while($row = mysql_fetch_array($query)){

echo '<option value="'.$row['sid'].'">'.$row['sname'].'</option>'

}

mysql_close($con)

?>保存为shi.php;

<?php

$con = @mysql_connect("localhost","root","")

if (!$con)

{

die('Could not connect: ' . mysql_error())

}

mysql_select_db("test", $con)

$pid = $_POST['pid']

$sql = "SELECT * FROM city where pid = $pid"

$query = mysql_query($sql)

while($row = mysql_fetch_array($query)){

//echo $row['pid']."<br />"

echo '<option value="'.$row['cid'].'">'.$row['cname'].'</option>'

}

mysql_close($con)

?>保存为city.php

希望帮到你。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7460602.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-05
下一篇 2023-04-05

发表评论

登录后才能评论

评论列表(0条)

保存