Results 1 to 6 of 6

Thread: SQL Join? ***Resolved***

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2002
    Location
    behind a pc
    Posts
    117

    SQL Join? ***Resolved***

    I have the following problem:

    a searchstring seperared by "+" or ",". Something like:

    me+you+we

    Table:

    Index IDCode name
    1 1 we
    2 1 me
    3 2 me
    4 2 you
    5 2 we
    6 3 we
    7 3 you

    I want to select only the IDCode that has all the names from the string. I have created some code to do this, but it is rather long. Is it possible to create a query who can do this and how?

    Thanks for the answer,

    danielsan
    Last edited by danielsan; Nov 29th, 2002 at 07:19 AM.
    Regards,

    danielsan

    'Even though the book is finished. There's no need to close and forget.'

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    this should do it:

    select * from table
    where idcode in (select idcode from table where name = "me")
    and idcode in (select idcode from table where name = "you")
    and idcode in (select idcode from table where name = "we")

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    ..and if you just want the idcodes change the first line to:
    select distinct idcode from table

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2002
    Location
    behind a pc
    Posts
    117
    sorry, but that didn't work...
    Regards,

    danielsan

    'Even though the book is finished. There's no need to close and forget.'

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    it worked for me, did you change the table name/field names to what you have in you database?

    what code did you use to run the SQL?

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Oct 2002
    Location
    behind a pc
    Posts
    117
    Sorry, my faliure. The error handler killed the sql-syntax error. I forgot a space somewhere.

    Thank you for taking the time to help me.

    Regards,

    danielsan
    Regards,

    danielsan

    'Even though the book is finished. There's no need to close and forget.'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width