![]() |
在mysql中如何用一个字段的值替换另一个字段的值
Q: 在同一个数据库中,先判断表A中的AID是否等于表B中的BID,如果是就用表A中的AC1的值去替换表B中的BC1的值。数据库为MYSQL,在PHPMYADMIN中操作,请问SQL命令该怎么写啊?
update b set bc1 = ( select ac1 from a where a.aid = b.bid)where exists (select 1 from ac1 where a.aid = b.bid) ========================== update b set b.bid=a.ac1 where a.aid=b.bid |
| All times are GMT +8. The time now is 03:35 AM. |
Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.