Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Too many results

Too many results

Scheduled Pinned Locked Moved Database
databasemysqltestingbeta-testinghelp
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John R Shaw
    wrote on last edited by
    #1

    I created a stored procedure in MySQL which returned one row in the result set. Since there is only one row in the table, this it what was supposed to happen. I had to add anouther column to the table, which I did without any problem. Then I modified the SELECT...FROM...WHERE query to include the column, no errors so it should be working correctly. The problem is that now it is returning 25 rows in the result set, all containing the same information. If I add another row to the table, it returns 50 rows - 25 copies of each row in the table. How is that possible?

    INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

    B 1 Reply Last reply
    0
    • J John R Shaw

      I created a stored procedure in MySQL which returned one row in the result set. Since there is only one row in the table, this it what was supposed to happen. I had to add anouther column to the table, which I did without any problem. Then I modified the SELECT...FROM...WHERE query to include the column, no errors so it should be working correctly. The problem is that now it is returning 25 rows in the result set, all containing the same information. If I add another row to the table, it returns 50 rows - 25 copies of each row in the table. How is that possible?

      INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      Can we see your query?


      I Love T-SQL

      J 1 Reply Last reply
      0
      • B Blue_Boy

        Can we see your query?


        I Love T-SQL

        J Offline
        J Offline
        John R Shaw
        wrote on last edited by
        #3

        [Message Deleted]

        B 1 Reply Last reply
        0
        • J John R Shaw

          [Message Deleted]

          B Offline
          B Offline
          Blue_Boy
          wrote on last edited by
          #4

          **WHERE locations.id = _locationID** This _locationID is parameter? If it is not parameter then must be table and u must specify column like : WHERE locations.id = _locationID**.Column** Also can u add in WHERE clause column destiny with any condition?


          I Love T-SQL

          J 1 Reply Last reply
          0
          • B Blue_Boy

            **WHERE locations.id = _locationID** This _locationID is parameter? If it is not parameter then must be table and u must specify column like : WHERE locations.id = _locationID**.Column** Also can u add in WHERE clause column destiny with any condition?


            I Love T-SQL

            J Offline
            J Offline
            John R Shaw
            wrote on last edited by
            #5

            Sorry I had to delete that mess. The 5 WHERE id compares and 5 SELECT IF() were the cause of the 25 returns - 5 x 5. The solution I came up with was to LEFT JOIN the series of required rows and remove the comparisons from the WHERE.

            FROM locations,
            loc_staticdata,
            loc_staticdata_waters AS sw
            LEFT JOIN textures AS d1 ON sw.surfaceTextureID = d1.id
            LEFT JOIN textures AS d2 ON sw.shoreTextureID = d2.id
            LEFT JOIN textures AS d3 ON sw.envMapOverTextureID = d3.id
            LEFT JOIN textures AS d4 ON sw.envMapUnderTextureID = d4.id
            LEFT JOIN textures AS d5 ON sw.specularMapTextureID = d5.id
            WHERE locations.id = _locationID
            AND locations.staticDataID = loc_staticdata.id
            AND sw.staticDataID = loc_staticdata.id;

            I am not sure if it is the best solution, but it works. Thanks for the attempt. :)

            INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

            B 1 Reply Last reply
            0
            • J John R Shaw

              Sorry I had to delete that mess. The 5 WHERE id compares and 5 SELECT IF() were the cause of the 25 returns - 5 x 5. The solution I came up with was to LEFT JOIN the series of required rows and remove the comparisons from the WHERE.

              FROM locations,
              loc_staticdata,
              loc_staticdata_waters AS sw
              LEFT JOIN textures AS d1 ON sw.surfaceTextureID = d1.id
              LEFT JOIN textures AS d2 ON sw.shoreTextureID = d2.id
              LEFT JOIN textures AS d3 ON sw.envMapOverTextureID = d3.id
              LEFT JOIN textures AS d4 ON sw.envMapUnderTextureID = d4.id
              LEFT JOIN textures AS d5 ON sw.specularMapTextureID = d5.id
              WHERE locations.id = _locationID
              AND locations.staticDataID = loc_staticdata.id
              AND sw.staticDataID = loc_staticdata.id;

              I am not sure if it is the best solution, but it works. Thanks for the attempt. :)

              INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

              B Offline
              B Offline
              Blue_Boy
              wrote on last edited by
              #6

              I am glad that u found solution, the most important is to work your query, the performance gonna be second with which we have to lookup... Happy query-ing... ;)


              I Love T-SQL

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups