DELIMITER $$

CREATE OR REPLACE DEFINER=`root`@`localhost` VIEW `qs_auth_table` AS
	SELECT 
		ua.idn,
		'xxx' AS GUID,
		ua.osobaGUID,
		ua.user_type AS typ,
		ua.login,
		ua.datas AS haslo,
		IFNULL((SELECT k.adres FROM kontakty k WHERE k.osobaGUID=ua.osobaGUID AND k.typ_medium=3 ORDER BY priorytet LIMIT 1),'s_dusza@koti.pl') AS mail,
		ua.date_from AS data_od,
		ua.date_to AS data_do,
		IF(ua.status=0,1,0) AS `status`,
		ua.LastUpdate,
		'0' AS RecType,
		'' AS ServerGUID
	FROM _user_accounts ua
	;
$$

DELIMITER ;


