Jump to content

MySQL help


zeezack

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/101352-mysql-help/
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/101352-mysql-help/#findComment-518449
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/101352-mysql-help/#findComment-518727
Share on other sites

 

 

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

Link to comment
https://forums.phpfreaks.com/topic/101352-mysql-help/#findComment-519301
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/101352-mysql-help/#findComment-520136
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.