Hay dos tablas abcd, efgh: -

Abcd: ID, fecha de venta, web, tipo.

Efgh - ID, fecha de pedido de ventas, evento, web, mmid.

Combinarlos con el nombre de la tabla como una de las columnas de donde se originó

0
DJKarma 25 feb. 2020 a las 08:39

2 respuestas

La mejor respuesta

Se utiliza UNION ALL y se supone que el tipo de datos de las columnas id y Library de la tabla 2 son respectivamente iguales:

select 
id, 
Library, 
Received_at_date, 
Browser, 
null as Event_date, 
null as Device_type, 
null as Screen_width, 
null as Screen_height, 
'Login_web' as value_from_table
from Login_web

UNION ALL

select 
id, 
Library, 
null as Received_at_date, 
null as Browser, 
Event_date, 
Device_type, 
Screen_width, 
Screen_height, 
'Login_app' as value_from_table
from Login_app
0
Grace 25 feb. 2020 a las 05:55

Puede usar UNION ALL para esta tarea.

SELECT WEB.ID,WEB.RECEIVED_AT_DATE,WEB.BROWSER,NULL AS EVENT_DATE,NULL AS DEVICE_TYPE,WEB.LIBRARY, NULL AS SCREEN_WIDTH,NULL AS SCREEN_HEIGHT, 'WEB' VALUE_FROM_TABLE FROM 
LOGIN_WEB WEB
UNION ALL
SELECT APP.ID,NULL AS RECEIVED_AT_DATE, NULL AS BROWSER,APP.EVENT_DATE,APP.DEVICE_TYPE,APP.LIBRARY,APP.SCREEN_WIDTH, APP.SCREEN_HEIGHT,'APP' VALUE_FROM_TABLE  FROM LOGIN_APP APP
0
ismetguzelgun 25 feb. 2020 a las 05:50