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. most efficient way to create query...

most efficient way to create query...

Scheduled Pinned Locked Moved Database
databasequestion
4 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.
  • A Offline
    A Offline
    adairjk
    wrote on last edited by
    #1

    I am trying to figure out the most efficient way to obtain and present a set of information.... I have a SQL table with information that is related to account numbers. There can be multiple lines with the same account number. I have a list of account numbers in a spreadsheet (about 100). I would like to know if there is at least one record in the table whose account number matches the number on the spreadsheet. Is there ane efficient way to give me a yes/no or other info without hitting the database 100 times? It could be done in Excel or VS2005. Does anyone want to throw out a suggestion? Much thanks in advance.

    M 1 Reply Last reply
    0
    • A adairjk

      I am trying to figure out the most efficient way to obtain and present a set of information.... I have a SQL table with information that is related to account numbers. There can be multiple lines with the same account number. I have a list of account numbers in a spreadsheet (about 100). I would like to know if there is at least one record in the table whose account number matches the number on the spreadsheet. Is there ane efficient way to give me a yes/no or other info without hitting the database 100 times? It could be done in Excel or VS2005. Does anyone want to throw out a suggestion? Much thanks in advance.

      M Offline
      M Offline
      Miszou
      wrote on last edited by
      #2

      select count( accountnumber ) from table where accountnumber in ( a, b, c ) That will tell you the number of accounts that match, where a, b and c (and so on) are account numbers.


      The StartPage Randomizer | The Timelapse Project | A Random Web Page

      A 1 Reply Last reply
      0
      • M Miszou

        select count( accountnumber ) from table where accountnumber in ( a, b, c ) That will tell you the number of accounts that match, where a, b and c (and so on) are account numbers.


        The StartPage Randomizer | The Timelapse Project | A Random Web Page

        A Offline
        A Offline
        adairjk
        wrote on last edited by
        #3

        This would give me the number of accounts that match, but not which of the accounts match....correct? I am needing to figure out which of the numbers match. Thanks.

        M 1 Reply Last reply
        0
        • A adairjk

          This would give me the number of accounts that match, but not which of the accounts match....correct? I am needing to figure out which of the numbers match. Thanks.

          M Offline
          M Offline
          Miszou
          wrote on last edited by
          #4

          select distinct accountnumber from table where accountnumber in ( a, b, c )


          The StartPage Randomizer | The Timelapse Project | A Random Web Page

          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