对于 Union,您会在什么现实情况下使用它?因为对我来说,对具有不同列用途/含义的两个表中的两个选择查询使用联合是没有意义的。例如:
表人:
id name age
1 mark 23
2 shawn 18
Run Code Online (Sandbox Code Playgroud)
表地址:
id personID address
1 1 some address
2 2 another random address
Run Code Online (Sandbox Code Playgroud)
根据上表,您会以什么方式或出于任何原因使用联合查询?
编辑
基本上我的理解是,为了提高效率,在将不同表中的类似信息处理到一张表中时使用 UNION,而不是总是单独查询或使用 JOIN 来处理类似信息。
编辑
或者当表(DB)的设计没有经过深思熟虑时。因为没有什么可以阻止任何人设计一个不完美的数据库,因为时间限制并且当您不知道表的最终设计的全部范围时。
这是代码:
#include <windows.h>
#include <windowsx.h>
// the WindowProc callback function prototype
LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
// win32 entry point
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
///*
// window handler
HWND hwnd;
// struct for window information
WNDCLASSEX wc;
// clear out the window class for use
ZeroMemory(&wc, sizeof(WNDCLASSEX));
// setting wc struct with window values/properties
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW); …Run Code Online (Sandbox Code Playgroud)