create or replace view webadmin_adapter.`v_in_auth_last_alive_out` AS
SELECT * FROM webadmin_adapter.auth ORDER BY id DESC LIMIT 0,1;


create or replace view webadmin_adapter.`v_in_i_user` AS SELECT * FROM `ISTRA_COMMON`.`IUSER`


create or replace view webadmin_adapter.`v_in_internal_address` AS SELECT * FROM `ISTRA_COMMON`.`INTERNALADDRESS`


create or replace view webadmin_adapter.`v_in_community` AS SELECT * FROM `ISTRA_COMMON`.`COMMUNITY`


CREATE OR REPLACE VIEW webadmin_adapter.`v_combined_data` AS
SELECT
    iuser.IUSERID,
    iuser.LOGIN,
    iuser.COMMUNITY,
    iuser.EXTENSIONS,
    internaladdress.INTERNALADDRESSID,
    internaladdress.ADDRESSNUMBER,
    internaladdress.ENTID AS internaladdress_ENTID,
    community.NAME,
    community.ENTID AS community_ENTID
FROM
    webadmin_adapter.`v_in_internal_address` AS internaladdress
        LEFT JOIN
    webadmin_adapter.`v_in_i_user` AS iuser ON internaladdress.ENTID = iuser.COMMUNITY
        LEFT JOIN
    webadmin_adapter.`v_in_community` AS community ON internaladdress.ENTID = community.ENTID;

