CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `pbx`.`sipConf`
AS SELECT `s`.`user_id` AS `id`,
	`s`.`extension` AS `name`,
	`s`.`extension` AS `regexten`,
	NULL AS `callbackextension`,
	`s`.`md5Secret` AS `md5secret`,
	`u`.`nickname` AS `callerid`,
	`c`.`host` AS `host`,
	`c`.`deny` AS `deny`,
	`c`.`permit` AS `permit`,
	`c`.`type` AS `type`,
	`c`.`context` AS `context`,
	`c`.`incomingLimit` AS `incominglimit`,
	`c`.`pickupGroup` AS `pickupgroup`,
	`c`.`directMedia` AS `directmedia`,
	`c`.`insecure` AS `insecure`,
	`c`.`transport` AS `transport`,
	`c`.`nat` AS `nat`,
	`c`.`disallow` AS `disallow`,
	`c`.`allow` AS `allow`,
	`r`.`ipAddr` AS `ipaddr`,
	`r`.`regSeconds` AS `regseconds`,
	`r`.`port` AS `port`,
	`r`.`defaultUser` AS `defaultuser`,
	`r`.`userAgent` AS `useragent`,
	`r`.`lastMs` AS `lastms`,
	`r`.`fullContact` AS `fullcontact`,
	`r`.`regServer` AS `regserver`
FROM (
		(
			(
				`pbx`.`sip` `s`
				JOIN `account`.`user` `u` ON(`u`.`id` = `s`.`user_id`)
			)
			LEFT JOIN `pbx`.`sipReg` `r` ON(`s`.`user_id` = `r`.`userId`)
		)
		JOIN `pbx`.`sipConfig` `c`
	)
