A表 id question B表 id aid title 判断question 是否为空 如果为空 选择B表 判断aid = id title是否存在 如果存在 读出内容插入A表就这样试着这写代码 去实现
$id = $_REQUEST['id']; $sql = "update a set a.question=(select b.title from a,b where a.id=b.aid and b.aid={$id}) where a.question='' and a.id={$id}";//后面执行代码该sql语句 $res = mysql_query($sql);
UPDATE a ,b SET a.question = b.title WHERE a.question = "" AND a.id=b.aid
update A set question=(select title from B where A.ID = B.ID) where question = "";你试试吧···不行的话 告诉我一声 学习一下啊··
$id = $_REQUEST['id']; $sql = "update a,b set a.question=b.title where a.question='' and a.id=b.aid and a.id={$id}"; //后面执行代码该sql语句 $res = mysql_query($sql); 以上代码经测试通过!
假如ID不是主键的话,你直接把表B的字段AID写入到表A的字段ID就可以了,并判断question是否为空
B表 id aid title
判断question 是否为空 如果为空 选择B表 判断aid = id title是否存在 如果存在 读出内容插入A表就这样试着这写代码 去实现
$id = $_REQUEST['id'];
$sql = "update a set a.question=(select b.title from a,b where a.id=b.aid and b.aid={$id}) where a.question='' and a.id={$id}";//后面执行代码该sql语句
$res = mysql_query($sql);
UPDATE a ,b SET a.question = b.title WHERE a.question = "" AND a.id=b.aid
$id = $_REQUEST['id'];
$sql = "update a,b set a.question=b.title where a.question='' and a.id=b.aid and a.id={$id}";
//后面执行代码该sql语句
$res = mysql_query($sql);
以上代码经测试通过!