I have a query from which I want to turn into a view:
SELECT * FROM `telefoonnummers`
WHERE `Afdeling` IN
(SELECT `Afdeling`
FROM
(
SELECT @a:=@a+1 as 'a'
,`Afdeling`
FROM `Afdeling-telefoon`
JOIN (SELECT @a:=0) x
ORDER BY `Afdeling`
) y WHERE mod(a,2) = 0) ORDER BY `Afdeling`, `Naam`
The only problem is I cant make a view out of this. It says it is not possible.
It returns:
#1349 - View's SELECT contains a subquery in the FROM clause
Any ideas how I could turn this into a view (or stored procedure maybe)?