mtgriffiths Posted March 18, 2008 Share Posted March 18, 2008 Hi all, When i am trying to add the below code to my database to create a view i am getting an error. If possible could someone point out where i am going wrong please? Thanks in advance Matthew CREATE VIEW Away_Points as select users.Team_Name AS Team_Name,sum(if((results.Goals2 > results.Goals1),3,if((results.Goals1 = results.Goals2),1,0))) ASAway_Points from (users join results on((users.user_id = results.Team2))) group by users.Team_Name order by sum(if((results.Goals2 > results.Goals1),3,if((results.Goals1 = results.Goals2),1,0))) ; Link to comment https://forums.phpfreaks.com/topic/96714-create-view/ Share on other sites More sharing options...
fenway Posted March 18, 2008 Share Posted March 18, 2008 What's the error? Link to comment https://forums.phpfreaks.com/topic/96714-create-view/#findComment-494884 Share on other sites More sharing options...
mtgriffiths Posted March 18, 2008 Author Share Posted March 18, 2008 The error is: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VIEW Away_Points as select users.Team_Name AS Team_Name,sum(if((results.Goals2 >' at line 1 Link to comment https://forums.phpfreaks.com/topic/96714-create-view/#findComment-494950 Share on other sites More sharing options...
fenway Posted March 18, 2008 Share Posted March 18, 2008 You're missing "SELECT"! Link to comment https://forums.phpfreaks.com/topic/96714-create-view/#findComment-494988 Share on other sites More sharing options...
mtgriffiths Posted March 18, 2008 Author Share Posted March 18, 2008 CREATE VIEW Away_Points as select users.Team_Name or do i have to have another select? Link to comment https://forums.phpfreaks.com/topic/96714-create-view/#findComment-494992 Share on other sites More sharing options...
fenway Posted March 18, 2008 Share Posted March 18, 2008 CREATE VIEW Away_Points as select users.Team_Name or do i have to have another select? Sorry, my eyes are tired today... what version of MySQL are you running? Link to comment https://forums.phpfreaks.com/topic/96714-create-view/#findComment-495054 Share on other sites More sharing options...
mtgriffiths Posted March 18, 2008 Author Share Posted March 18, 2008 Version is 5.0.45 I have been using phpmyadmin to create my tables tho Link to comment https://forums.phpfreaks.com/topic/96714-create-view/#findComment-495060 Share on other sites More sharing options...
mtgriffiths Posted March 18, 2008 Author Share Posted March 18, 2008 I have run the query on my localhost and it works fine. When i run it on the internet i have the above error Link to comment https://forums.phpfreaks.com/topic/96714-create-view/#findComment-495062 Share on other sites More sharing options...
fenway Posted March 18, 2008 Share Posted March 18, 2008 I have run the query on my localhost and it works fine. When i run it on the internet i have the above error And you're sure that both are version 5? Link to comment https://forums.phpfreaks.com/topic/96714-create-view/#findComment-495076 Share on other sites More sharing options...
mtgriffiths Posted March 18, 2008 Author Share Posted March 18, 2008 Looking at it on the internet it says: MySQL client version: 4.1.22 Im guessing that as its older it wont allow it? Any idea how i can get around this as its very important to my assignment Thanks again Link to comment https://forums.phpfreaks.com/topic/96714-create-view/#findComment-495081 Share on other sites More sharing options...
fenway Posted March 19, 2008 Share Posted March 19, 2008 That's right -- no views prior to v5+. You could always make a temporary table.... Link to comment https://forums.phpfreaks.com/topic/96714-create-view/#findComment-495869 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.