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. One more query problem

One more query problem

Scheduled Pinned Locked Moved Database
databasehelp
3 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.
  • S Offline
    S Offline
    sujithkumarsl
    wrote on last edited by
    #1

    Suppose i have a table like this..

    COL1 COL2 COL3
    X 100 1
    X 200 2
    X 300 3
    Y 100 1
    Y 200 2
    Z 300 1

    i want to select col1 where 100=1 and 200=2 and 300=3

    My small attempt...

    M N 2 Replies Last reply
    0
    • S sujithkumarsl

      Suppose i have a table like this..

      COL1 COL2 COL3
      X 100 1
      X 200 2
      X 300 3
      Y 100 1
      Y 200 2
      Z 300 1

      i want to select col1 where 100=1 and 200=2 and 300=3

      My small attempt...

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      In the where clause convert both col2 & 3 to strings and compare the first character of each.

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      • S sujithkumarsl

        Suppose i have a table like this..

        COL1 COL2 COL3
        X 100 1
        X 200 2
        X 300 3
        Y 100 1
        Y 200 2
        Z 300 1

        i want to select col1 where 100=1 and 200=2 and 300=3

        My small attempt...

        N Offline
        N Offline
        Niladri_Biswas
        wrote on last edited by
        #3

        Solution 1:

        SELECT COL1
        FROM tbl_Test
        WHERE COL2 = (COL3 * 100);

        Solution 2:

        SELECT COL1
        FROM tbl_Test
        WHERE (COL2 = 100 AND COL3 = 1)
        OR (COL2 = 200 AND COL3 = 2)
        OR (COL2 = 300 AND COL3 = 3)

        Solution 3:

        select COL1
        from tbl_Test
        where ( (COL2=100 and COL3=1) or (COL2=200 and COL3=2) or (COL2=300 and COL3=3) )

        Please vote :)

        Niladri Biswas

        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