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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Select statment

Select statment

Scheduled Pinned Locked Moved Database
5 Posts 4 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
    Amarni
    wrote on last edited by
    #1

    i want to make an select statment like that select * from Table_name Where ID=2 and ID=4 and ID=5 while the Id in not the primery key amarni

    C 1 Reply Last reply
    0
    • A Amarni

      i want to make an select statment like that select * from Table_name Where ID=2 and ID=4 and ID=5 while the Id in not the primery key amarni

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

      Amarni wrote:

      select * from Table_name Where ID=2 and ID=4 and ID=5 while the Id in not the primery key

      I don't understand what you are trying do do here. Perhaps if you explained without trying to write in Pseudo-SQL it would be more helpful As far as I can tell you want All columns from rows where the Id column is equal to 2, 4 and 5 all at the same time. I really don't undersrtand what you mean by "the Id in not the Primary Key". The Id column is either the primary key or it isn't and that will apply to all rows in the table.


      Scottish Developers events: * .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

      A 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Amarni wrote:

        select * from Table_name Where ID=2 and ID=4 and ID=5 while the Id in not the primery key

        I don't understand what you are trying do do here. Perhaps if you explained without trying to write in Pseudo-SQL it would be more helpful As far as I can tell you want All columns from rows where the Id column is equal to 2, 4 and 5 all at the same time. I really don't undersrtand what you mean by "the Id in not the Primary Key". The Id column is either the primary key or it isn't and that will apply to all rows in the table.


        Scottish Developers events: * .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

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

        sorry it is not primery key but i need this imagine that i have three table x has X_ID(Primery) and Name,..... atrribute y has Y_ID(Primery) and desc,..... atrribute the relation between them is many to many so that i creat a table between them named xy that conatain both IDs X_ID and y_ID so that i want to make select statment like that select * from x Where Y_ID=2 and Y_ID=4 and Y_ID=5 i hope you understatnd it now Amarni

        S P 2 Replies Last reply
        0
        • A Amarni

          sorry it is not primery key but i need this imagine that i have three table x has X_ID(Primery) and Name,..... atrribute y has Y_ID(Primery) and desc,..... atrribute the relation between them is many to many so that i creat a table between them named xy that conatain both IDs X_ID and y_ID so that i want to make select statment like that select * from x Where Y_ID=2 and Y_ID=4 and Y_ID=5 i hope you understatnd it now Amarni

          S Offline
          S Offline
          Subramaniam s V
          wrote on last edited by
          #4

          Could you please post exactly what you want to arrive ?

          1 Reply Last reply
          0
          • A Amarni

            sorry it is not primery key but i need this imagine that i have three table x has X_ID(Primery) and Name,..... atrribute y has Y_ID(Primery) and desc,..... atrribute the relation between them is many to many so that i creat a table between them named xy that conatain both IDs X_ID and y_ID so that i want to make select statment like that select * from x Where Y_ID=2 and Y_ID=4 and Y_ID=5 i hope you understatnd it now Amarni

            P Offline
            P Offline
            Paddy Boyd
            wrote on last edited by
            #5

            I think you just want a join like this:

            SELECT DISTINCT x.*
            FROM x
            INNER JOIN xy
            ON x.x_id = xy.x_id
            WHERE xy.y_id in (2,4,5)

            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