How to you set a table name to a correlation name in PHP for a SQL database?









up vote
0
down vote

favorite












I am trying to write a line of code in PHP, and this is probably a stupid question but I'm new to coding. I get this error when I try to run my php page:




"Error in query preparation/execution. Array ( [0] => Array ( [0] =>
42000 [SQLSTATE] => 42000 [1] => 1013 [code] => 1013 [2] =>
[Microsoft][SQL Server Native Client 11.0][SQL Server]The objects
"ACTION" and "action" in the FROM clause have the same exposed names.
Use correlation names to distinguish them. [message] =>
[Microsoft][SQL Server Native Client 11.0][SQL Server]The objects
"ACTION" and "action" in the FROM clause have the same exposed names.
Use correlation names to distinguish them. ) )"




My question is simply how do I use a correlation name for the table name? I have a table called "action" and I am trying to write a statement that contains inner joins, so the database doesn't like that I'm trying to perform the INNER JOIN ACTION on my action table.. go figure!



I've tried to research it, but I keep finding complex examples of setting correlation names. Any help is greatly appreciated!










share|improve this question



























    up vote
    0
    down vote

    favorite












    I am trying to write a line of code in PHP, and this is probably a stupid question but I'm new to coding. I get this error when I try to run my php page:




    "Error in query preparation/execution. Array ( [0] => Array ( [0] =>
    42000 [SQLSTATE] => 42000 [1] => 1013 [code] => 1013 [2] =>
    [Microsoft][SQL Server Native Client 11.0][SQL Server]The objects
    "ACTION" and "action" in the FROM clause have the same exposed names.
    Use correlation names to distinguish them. [message] =>
    [Microsoft][SQL Server Native Client 11.0][SQL Server]The objects
    "ACTION" and "action" in the FROM clause have the same exposed names.
    Use correlation names to distinguish them. ) )"




    My question is simply how do I use a correlation name for the table name? I have a table called "action" and I am trying to write a statement that contains inner joins, so the database doesn't like that I'm trying to perform the INNER JOIN ACTION on my action table.. go figure!



    I've tried to research it, but I keep finding complex examples of setting correlation names. Any help is greatly appreciated!










    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am trying to write a line of code in PHP, and this is probably a stupid question but I'm new to coding. I get this error when I try to run my php page:




      "Error in query preparation/execution. Array ( [0] => Array ( [0] =>
      42000 [SQLSTATE] => 42000 [1] => 1013 [code] => 1013 [2] =>
      [Microsoft][SQL Server Native Client 11.0][SQL Server]The objects
      "ACTION" and "action" in the FROM clause have the same exposed names.
      Use correlation names to distinguish them. [message] =>
      [Microsoft][SQL Server Native Client 11.0][SQL Server]The objects
      "ACTION" and "action" in the FROM clause have the same exposed names.
      Use correlation names to distinguish them. ) )"




      My question is simply how do I use a correlation name for the table name? I have a table called "action" and I am trying to write a statement that contains inner joins, so the database doesn't like that I'm trying to perform the INNER JOIN ACTION on my action table.. go figure!



      I've tried to research it, but I keep finding complex examples of setting correlation names. Any help is greatly appreciated!










      share|improve this question















      I am trying to write a line of code in PHP, and this is probably a stupid question but I'm new to coding. I get this error when I try to run my php page:




      "Error in query preparation/execution. Array ( [0] => Array ( [0] =>
      42000 [SQLSTATE] => 42000 [1] => 1013 [code] => 1013 [2] =>
      [Microsoft][SQL Server Native Client 11.0][SQL Server]The objects
      "ACTION" and "action" in the FROM clause have the same exposed names.
      Use correlation names to distinguish them. [message] =>
      [Microsoft][SQL Server Native Client 11.0][SQL Server]The objects
      "ACTION" and "action" in the FROM clause have the same exposed names.
      Use correlation names to distinguish them. ) )"




      My question is simply how do I use a correlation name for the table name? I have a table called "action" and I am trying to write a statement that contains inner joins, so the database doesn't like that I'm trying to perform the INNER JOIN ACTION on my action table.. go figure!



      I've tried to research it, but I keep finding complex examples of setting correlation names. Any help is greatly appreciated!







      php sql sql-server






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 25 '13 at 4:33









      Ryan

      17.7k74580




      17.7k74580










      asked Apr 25 '13 at 4:28









      Kelley

      31




      31






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          Check out this article for more details on how to do this. It comes down to what Ryan showed but gives a bit more details.




          • Using Table Aliases (MSDN)

          Also here is another good reading on how to use these correctly with a lot of examples.



          • Bad habits to kick : using table aliases like (a, b, c) or (t1, t2, t3)





          share|improve this answer


















          • 1




            Thank you! The examples definitely help. Something so simple, but I just wasn't familiar with it.
            – Kelley
            May 8 '13 at 0:12

















          up vote
          0
          down vote













          You just need to use unique aliases for each case where you use the action table. You did not show your query, but it would be something like this:



          SELECT *
          FROM ACTION a1
          INNER JOIN ACTION a2 ON ...


          This way, the intended use of each instance of the same table is clear to the query parser.






          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16206393%2fhow-to-you-set-a-table-name-to-a-correlation-name-in-php-for-a-sql-database%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            Check out this article for more details on how to do this. It comes down to what Ryan showed but gives a bit more details.




            • Using Table Aliases (MSDN)

            Also here is another good reading on how to use these correctly with a lot of examples.



            • Bad habits to kick : using table aliases like (a, b, c) or (t1, t2, t3)





            share|improve this answer


















            • 1




              Thank you! The examples definitely help. Something so simple, but I just wasn't familiar with it.
              – Kelley
              May 8 '13 at 0:12














            up vote
            1
            down vote



            accepted










            Check out this article for more details on how to do this. It comes down to what Ryan showed but gives a bit more details.




            • Using Table Aliases (MSDN)

            Also here is another good reading on how to use these correctly with a lot of examples.



            • Bad habits to kick : using table aliases like (a, b, c) or (t1, t2, t3)





            share|improve this answer


















            • 1




              Thank you! The examples definitely help. Something so simple, but I just wasn't familiar with it.
              – Kelley
              May 8 '13 at 0:12












            up vote
            1
            down vote



            accepted







            up vote
            1
            down vote



            accepted






            Check out this article for more details on how to do this. It comes down to what Ryan showed but gives a bit more details.




            • Using Table Aliases (MSDN)

            Also here is another good reading on how to use these correctly with a lot of examples.



            • Bad habits to kick : using table aliases like (a, b, c) or (t1, t2, t3)





            share|improve this answer














            Check out this article for more details on how to do this. It comes down to what Ryan showed but gives a bit more details.




            • Using Table Aliases (MSDN)

            Also here is another good reading on how to use these correctly with a lot of examples.



            • Bad habits to kick : using table aliases like (a, b, c) or (t1, t2, t3)






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 10 at 22:04









            Aaron Bertrand

            207k27361404




            207k27361404










            answered Apr 25 '13 at 8:50









            Frank Baker

            1614




            1614







            • 1




              Thank you! The examples definitely help. Something so simple, but I just wasn't familiar with it.
              – Kelley
              May 8 '13 at 0:12












            • 1




              Thank you! The examples definitely help. Something so simple, but I just wasn't familiar with it.
              – Kelley
              May 8 '13 at 0:12







            1




            1




            Thank you! The examples definitely help. Something so simple, but I just wasn't familiar with it.
            – Kelley
            May 8 '13 at 0:12




            Thank you! The examples definitely help. Something so simple, but I just wasn't familiar with it.
            – Kelley
            May 8 '13 at 0:12












            up vote
            0
            down vote













            You just need to use unique aliases for each case where you use the action table. You did not show your query, but it would be something like this:



            SELECT *
            FROM ACTION a1
            INNER JOIN ACTION a2 ON ...


            This way, the intended use of each instance of the same table is clear to the query parser.






            share|improve this answer
























              up vote
              0
              down vote













              You just need to use unique aliases for each case where you use the action table. You did not show your query, but it would be something like this:



              SELECT *
              FROM ACTION a1
              INNER JOIN ACTION a2 ON ...


              This way, the intended use of each instance of the same table is clear to the query parser.






              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                You just need to use unique aliases for each case where you use the action table. You did not show your query, but it would be something like this:



                SELECT *
                FROM ACTION a1
                INNER JOIN ACTION a2 ON ...


                This way, the intended use of each instance of the same table is clear to the query parser.






                share|improve this answer












                You just need to use unique aliases for each case where you use the action table. You did not show your query, but it would be something like this:



                SELECT *
                FROM ACTION a1
                INNER JOIN ACTION a2 ON ...


                This way, the intended use of each instance of the same table is clear to the query parser.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 25 '13 at 4:32









                Ryan

                17.7k74580




                17.7k74580



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16206393%2fhow-to-you-set-a-table-name-to-a-correlation-name-in-php-for-a-sql-database%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Use pre created SQLite database for Android project in kotlin

                    Darth Vader #20

                    Ondo