vfp?
这样写:
select * from user into table temp
select temp.姓名, temp.卡号, temp.地址, phone.电话 from temp left join phone on temp.姓名=phone.姓名 into table user
注意:
select * from user into table temp
不能写做
select * from user into cursor temp
因为下一句要用到左连接,不能使用临时表
而第二句不使用左连接的话,将丢失user表中没有电话记录
你也可以写做
select user.姓名, user.卡号, user.地址, phone.电话 from user left join phone on user.姓名=phone.姓名 into cursor temp
select * from temp into table user
这样可能好一些
ALTER TABLE `user` ADD 电话 varchar(30) not null;
UPDATE `user`, phone
SET `user`.电话=phone.电话
WHERE `user`.姓名=phone.姓名;
----MYSQL3.23----
CREATE TEMPORARY TABLE new_user
SELECT u.*,p.电话
FROM `user` AS u
LEFT JOIN phone AS p ON u.姓名=p.姓名;
DROP TABLE `user`;
CREATE TABLE `user`
SELECT * FROM new_user;