zeezack Posted April 16, 2008 Share Posted April 16, 2008 What is wrong with this statement? SELECT ACTION_CODE ACTION_CODE,ACTION_LEVEL ACTION_LEVEL,ACTION_MASTER ACTION_MASTER FROM ( SELECT alias.ACTION_CODE ,alias.ACTION_LEVEL ,alias.ACTION_MASTER , rownum r FROM ( SELECT ACTION_CODE ,ACTION_LEVEL ,ACTION_MASTER FROM ACTION_CODES ORDER BY ACTION_CODE ) alias WHERE rownum <= 4 ) WHERE r > 4 Quote Link to comment https://forums.phpfreaks.com/topic/101352-mysql-help/ Share on other sites More sharing options...
Cep Posted April 16, 2008 Share Posted April 16, 2008 Your field names have spaces, and I am guessing this is causing the SQL statement to fail, you need to surround field names with spaces in parenthesis of some kind. Quote Link to comment https://forums.phpfreaks.com/topic/101352-mysql-help/#findComment-518396 Share on other sites More sharing options...
zeezack Posted April 16, 2008 Author Share Posted April 16, 2008 I think I have sorted out the spaces..but I still get an error? Is the mysql wrong..do I need to make an AS or something? SELECT ACTION_CODE ACTION_CODE,ACTION_LEVEL ACTION_LEVEL,ACTION_MASTER ACTION_MASTER FROM ( SELECT alias.ACTION_CODE,alias.ACTION_LEVEL,alias.ACTION_MASTER, rownum r FROM ( SELECT ACTION_CODE,ACTION_LEVEL,ACTION_MASTER FROM ACTION_CODES ORDER BY ACTION_CODE ) alias WHERE rownum <= 4 ) WHERE r > 4 Quote Link to comment https://forums.phpfreaks.com/topic/101352-mysql-help/#findComment-518449 Share on other sites More sharing options...
Cep Posted April 16, 2008 Share Posted April 16, 2008 That code still has spaces, ACTION_CODE ACTION_CODE ACTION_LEVEL ACTION_LEVEL ACTION_MASTER ACTION_MASTER Quote Link to comment https://forums.phpfreaks.com/topic/101352-mysql-help/#findComment-518486 Share on other sites More sharing options...
zeezack Posted April 16, 2008 Author Share Posted April 16, 2008 I am actually translating a PERL page to PHP... according to the code... those spaces should be there? Quote Link to comment https://forums.phpfreaks.com/topic/101352-mysql-help/#findComment-518512 Share on other sites More sharing options...
Cep Posted April 16, 2008 Share Posted April 16, 2008 Then it is wrong, you cannot have spaces like that in an SQL statement for field names without surrounding them in parenthesis, this doesn't matter if its PERL, PHP, VB.NET, they are field names from the table/s you are basing the SELECT on and the space will cause the statement to error. I imagine, that you may be using Constants to dynamically select fields but if thats the case you need to do this differently. Can you tell me what they are meant to be? Are they field names or some sort of constant or variable used to set the field name? Quote Link to comment https://forums.phpfreaks.com/topic/101352-mysql-help/#findComment-518727 Share on other sites More sharing options...
zeezack Posted April 17, 2008 Author Share Posted April 17, 2008 Oracle issue - this is connecting to an oracle database sooooo the sql for this according to the document should be SELECT ACTION_CODE ACTION_CODE,ACTION_LEVEL ACTION_LEVEL, ACTION_MASTER ACTION_MASTER FROM (SELECT alias.ACTION_CODE, alias.ACTION_LEVEL, alias.ACTION_MASTER, rownum r FROM ( SELECT ACTION_CODE,ACTION_LEVEL,ACTION_MASTER FROM ACTION_CODES ORDER BY ACTION_CODE ) alias WHERE rownum <= 4 ) WHERE r > 4 Quote Link to comment https://forums.phpfreaks.com/topic/101352-mysql-help/#findComment-519301 Share on other sites More sharing options...
Cep Posted April 18, 2008 Share Posted April 18, 2008 So let me get this straight, you asked a question about MySQL, in a PHP forum, for an Oracle database? I don't think you could get any more confusing, if this is Oracle you are writing the script for here is a tutorial on Oracle's SQL http://dbis.ucdavis.edu/courses/sqltutorial/tutorial.pdf Quote Link to comment https://forums.phpfreaks.com/topic/101352-mysql-help/#findComment-520136 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.