我在MYSQL中有两个表:
T1 T2
现在这是我的问题。 T1包含:
id = 1
name = name1
fname = fname1
SIRB no. = SIRB123456789
SIRB expiry = 2016 June 01
id = 2
name = name2
fname = fname2
SIRB no. = SIRB12345
SIRB expiry = 2016 June 01
id = 3
name = name3
fname = fname3
SIRB no. = SIRBof3
SIRB expiry = 2016 June 01
和第二个表:
id = 1
name = name1
fname = fname1
VISA no. = null
VISA expiry = null
id = 2
name = name2
fname = fname2
VISA no. = null
VISA expiry = null
id = 3
name = name3
fname = fname3
VISA no. = VISA123
VISA expiry = 2016 June 1
我的问题是我想将这个表合并为一个,所以我的最终表格就像:
id = 1
name = name1
fname = fname1
SIRB no. = SIRB123456789
SIRB expiry = 2016 June 01
VISA no. = null
VISA expiry = null
id = 2
name = name2
fname = fname2
SIRB no. = SIRB12345
SIRB expiry = 2016 June 01
VISA no. = null
VISA expiry = null
id = 3
name = name3
fname = fname3
SIRB no. = SIRBof3
SIRB expiry = 2016 June 01
VISA no. = VISA123
VISA expiry = 2016 June 1
假设这是在一张桌子上,只有三列(现在无法上传图片,所以请耐心等待。)
答案 0 :(得分:0)
您可以使用所需的列创建表格。然后,首先直接从一个表插入数据,然后如果来自另一个表的列更新其余数据,或者创建已加入数据的选择查询。
确切的查询取决于您如何加入表格。我假设我的字段不匹配,所以你可能必须使用这个名称,如果它是唯一的。