MySQL Forums
Forum List  »  General

Query not working when trying to create view
Posted by: Ben Nicholl
Date: April 04, 2019 10:52AM

I have a query that works fine. The query is:

select ChannelID, userID, viewID, EventType, EventInfo, ChannelName, FirstName, channelPageName

from (select _nc15_channel_user.ChannelID, userID, _nc15_channel_user_view.viewID, EventType, EventInfo, ChannelName, FirstName, channelPageName
from _nc15_channel_user_view_events
inner join _nc15_channel_user_view on _nc15_channel_user_view_events.ViewID = _nc15_channel_user_view.viewID
inner join _nc15_channel_user on _nc15_channel_user_view.userID = _nc15_channel_user.ChannelUserID
inner join _nc15_channel on _nc15_channel_user.channelID = _nc15_channel.channelID
left join _nc15_channel_pages on _nc15_channel.channelID = _nc15_channel_pages.channelID

where CreateTime >= '2019-01-01'
and _nc15_channel_user.channelID in (340,307,360,433,358,436,394,403,389,396,450,448,449)
and emailAddress not like '%.%@mngdirect.com'
and emailAddress not like '%nexgen%'
and emailAddress not like '%@merck%'
and emailAddress not like '%@250ok%'
and Firstname != '250ok'
and emailAddress not like '%@061618mngdirect.com%') as joined_tables


but when I try and turn it into a view:

CREATE VIEW `new_view` AS

select ChannelID, userID, viewID, EventType, EventInfo, ChannelName, FirstName, channelPageName

from (select _nc15_channel_user.ChannelID, userID, _nc15_channel_user_view.viewID, EventType, EventInfo, ChannelName, FirstName, channelPageName
from _nc15_channel_user_view_events
inner join _nc15_channel_user_view on _nc15_channel_user_view_events.ViewID = _nc15_channel_user_view.viewID
inner join _nc15_channel_user on _nc15_channel_user_view.userID = _nc15_channel_user.ChannelUserID
inner join _nc15_channel on _nc15_channel_user.channelID = _nc15_channel.channelID
left join _nc15_channel_pages on _nc15_channel.channelID = _nc15_channel_pages.channelID

where CreateTime >= '2019-01-01'
and _nc15_channel_user.channelID in (340,307,360,433,358,436,394,403,389,396,450,448,449)
and emailAddress not like '%.%@mngdirect.com'
and emailAddress not like '%nexgen%'
and emailAddress not like '%@merck%'
and emailAddress not like '%@250ok%'
and Firstname != '250ok'
and emailAddress not like '%@061618mngdirect.com%') as joined_tables


and click apply, I get an error message: Error: There was an error while applying the SQL script to the database.

Anyone know how to remedy this?

Options: ReplyQuote


Subject
Written By
Posted
Query not working when trying to create view
April 04, 2019 10:52AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.