我正在尝试执行以下任务。我有2个表格,包含以下数据?
表1:
objectid name LOCATION Project Manager
4584 Client NULL Indicator
4591 Ericsson NULL Indicator
4604 NEW201 Text NULL
表2:
projectobjectid name value
4584 Indicator Red
4591 Indicator Green
4604 Text Sf001-bb1-5
4604 Text Sf001-bb1-4
4604 Text Sf001-bb1-3
4604 Text Sf001-bb1-2
结果如下:
objectid name LOCATION Project Manager
4584 Client NULL Red
4591 Ericsson NULL Green
4604 NEW201 Sf001-bb1-5 NULL
4604 NEW201 Sf001-bb1-4 NULL
4604 NEW201 Sf001-bb1-3 NULL
4604 NEW201 Sf001-bb1-2 NULL
更新表2中的表1.
答案 0 :(得分:2)
您可以使用两个bl_info = {
"name": "Export Roblox Mesh (.mesh)",
"description": "Exports the selected model to .mesh Source: http://www.roblox.com/BlenderExport-py-item?id=25895023",
"author": "Original by stravant, then edited",
"version": (1,0),
"location": "File > Export",
"warning": "",
"wiki_url": "http://www.roblox.com/BlenderExport-py-item?id=25895023",
"category": "Import-Export"
}
import bpy
def get_face_vertex_array(face, uvface, mesh, matrix):
varray = []
for inx, verti in enumerate(face.vertices):
tcoord = (matrix * mesh.vertices[verti].co).to_tuple(3)
tnorm = (matrix.to_3x3() * face.normal).normalized().to_tuple(3)
tuv = (0,0,0)
varray.append((tcoord, tnorm, tuv))
return varray
def write_tuple_3(tuple, file, flip):
if flip:
file.write("["+str(tuple[0])+","+str(tuple[2])+","+str(tuple[1])+"]")
else:
file.write("["+str(tuple[0])+","+str(tuple[1])+","+str(tuple[2])+"]")
def write_verts(varray, nverts, file):
file.write(str(nverts) + "\n")
for vert in varray:
write_tuple_3(vert[0], file, True)
write_tuple_3(vert[1], file, True)
write_tuple_3(vert[2], file, False)
file.write("\n")
def do_export(path,selected_only):
file = open(path, "w")
file.write("version 1.00\n")
tmp_mesh_verts = []
tmp_mesh_size = 0
invert_rot = False
scene = bpy.context.scene
for obj in (selected_only and bpy.context.selected_objects or bpy.data.objects):
if obj.type == "MESH":
tmp_mesh = obj.to_mesh(scene,True, "PREVIEW")
matrix = obj.matrix_world.copy()
for index, face in enumerate(tmp_mesh.tessfaces):
verts = get_face_vertex_array(face, None, tmp_mesh, matrix)
if len(verts) > 3:
if invert_rot:
tmp_mesh_verts.extend([verts[2], verts[1], verts[0], verts[3], verts[2], verts[0]])
else:
tmp_mesh_verts.extend([verts[0], verts[1], verts[2], verts[0], verts[2], verts[3]])
tmp_mesh_size += 2
else:
if invert_rot:
tmp_mesh_verts.extend([verts[2], verts[1], verts[0]])
else:
tmp_mesh_verts.extend([verts[0], verts[1], verts[2]])
tmp_mesh_size += 1
bpy.data.meshes.remove(tmp_mesh)
write_verts(tmp_mesh_verts, tmp_mesh_size, file)
file.close()
class RbxExporter(bpy.types.Operator):
"""Export model to .mesh"""
bl_idname = "export.mesh"
bl_label = "Export RBXMesh"
filepath = bpy.props.StringProperty(subtype="FILE_PATH")
ending = bpy.props.StringProperty(name="File ending", description="The file ending to be used", maxlen= 1024, default= ".mesh")
selected_only = bpy.props.BoolProperty(name="Selected objects only", description="Export only the selected objects?", default= False)
def execute(self, context):
print("RBX::Execute")
do_export(self.filepath + (self.filepath.endswith(self.ending) and "" or self.ending),self.selected_only)
return {"FINISHED"}
def invoke(self, context, event):
print("RBX::Invoke")
context.window_manager.fileselect_add(self)
return {"RUNNING_MODAL"}
def menu_func(self, context):
print("RBX::MenuFunc")
self.layout.operator(RbxExporter.bl_idname, text="Roblox Mesh (.mesh)")
def register():
print("RBX::Register")
bpy.utils.register_class(RbxExporter)
bpy.types.INFO_MT_file_export.append(menu_func)
def unregister():
print("RBX::Unregister")
bpy.utils.unregister_class(RbxExporter)
bpy.types.INFO_MT_file_export.remove(menu_func)
if __name__ == "__main__":
register()
执行此操作,每个要替换的列对应一个:
left join
答案 1 :(得分:1)
你去(只有一个左连接):
SELECT t1.objectid, t1.name,
CASE t1.location WHEN t2.name THEN t2.value END as Location,
CASE t1.projectmanager WHEN t2.name THEN t2.value END as ProjectManager
FROM table1 t1
LEFT JOIN table2 t2 ON t2.projectobjectid=t1.objectid