Results 1 to 4 of 4

Thread: [RESOLVED] remove single value from query

  1. #1

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Resolved [RESOLVED] remove single value from query

    Hey all
    I have 2 tables A & B
    Table A
    id name suffixID
    0 him 0
    1 her 1
    2 it 2

    Table B
    id name isActive
    0 Mr. 1
    1 Mrs. 1
    2 other 0


    and this query...
    SELECT A.name as Name,B.name as Suffix
    FROM A
    LEFT JOIN B ON A.suffixID = B.id

    should return a table like this (unless my syntax is off which is quite possible)...
    Table C
    Name Suffix
    him Mr.
    her Mrs.
    it other
    What I need to do is eliminate the value for B.name whereever B.isActive=0. I don't want to remove the row, just the value in the row to have something like this...
    Table C
    Name Suffix
    him Mr.
    her Mrs.
    it
    Can anyone tell me how to adjust the sql to achieve that?
    Thanks
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: remove single value from query

    just add it to the join:
    Code:
    SELECT A.name as Name,B.name as Suffix
    FROM A
    LEFT JOIN B ON A.suffixID = B.id and B.isActive = 1
    Now the join will only include those that are marked isActive.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: remove single value from query

    you make it seem so simple.
    thanks tg
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: remove single value from query

    Quote Originally Posted by kebo View Post
    you make it seem so simple.
    thanks tg
    kevin
    It's a curse...


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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