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. want to get only one row(first one) when multiple rows are present in a table.....

want to get only one row(first one) when multiple rows are present in a table.....

Scheduled Pinned Locked Moved Database
4 Posts 3 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.
  • K Offline
    K Offline
    Khawar Abbas1
    wrote on last edited by
    #1

    I want to get only one row(first one) when multiple rows are present in a table..... e.g Prof ID -- Item -- Date 1 -- Mango -- 1-1-2005 1 -- Orange -- 2-1-2005 1 -- Apple -- 3-1-2005 2 -- Orange -- 2-1-2005 2 -- Apple -- 3-1-2005 I want this result: Prof ID -- Item -- Date 1 -- Mango -- 1-1-2005 2 -- Orange -- 2-1-2005

    Do good and have good.

    C 1 Reply Last reply
    0
    • K Khawar Abbas1

      I want to get only one row(first one) when multiple rows are present in a table..... e.g Prof ID -- Item -- Date 1 -- Mango -- 1-1-2005 1 -- Orange -- 2-1-2005 1 -- Apple -- 3-1-2005 2 -- Orange -- 2-1-2005 2 -- Apple -- 3-1-2005 I want this result: Prof ID -- Item -- Date 1 -- Mango -- 1-1-2005 2 -- Orange -- 2-1-2005

      Do good and have good.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      That depends on your idea of what is first. Strictly speaking the rows in a database have no order although the underlying database software will put the data in a certain order it should always be thought of as unordered because the software may change and the previously implied order with it. So, given that a database is an unordered set of data, how do you define first? What do you want to put in the ORDER BY clause? Then we can figure out how to get the first of each series.


      Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos

      K 1 Reply Last reply
      0
      • C Colin Angus Mackay

        That depends on your idea of what is first. Strictly speaking the rows in a database have no order although the underlying database software will put the data in a certain order it should always be thought of as unordered because the software may change and the previously implied order with it. So, given that a database is an unordered set of data, how do you define first? What do you want to put in the ORDER BY clause? Then we can figure out how to get the first of each series.


        Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos

        K Offline
        K Offline
        Khawar Abbas1
        wrote on last edited by
        #3

        infact i want to get just one record against "Prof ID". Order is not necessary here.... Waiting for reply

        Do good and have good.

        R 1 Reply Last reply
        0
        • K Khawar Abbas1

          infact i want to get just one record against "Prof ID". Order is not necessary here.... Waiting for reply

          Do good and have good.

          R Offline
          R Offline
          RSArockiam
          wrote on last edited by
          #4

          Use simplest way that is GROUP BY option

          Regards R.Arockiapathinathan

          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