How to hide critera in search results?

  • say i want to search for a range of account numbers but only which are active. After I set my field for A (active) this field shows in my results, I dont want it to.

    In Access you can easily just uncheck that field in design view, but how do I do it in sql?

    Thanks

  • You are using the UI, correct?

    Well, don't do that! 🙂

    SELECT Field_I_DO_Want_To_See1, Field_I_DO_Want_To_See2, Field_I_DO_Want_To_See3

    FROM SomeTable

    WHERE Field_I_Do_Not_Want_To_See = 'Foo'

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • What do you mean by UI? User Interface? I am using microsoft sql management studio.

    Heres my code, at the end I am only looking for active accounts. So in my results they came with a column of A. I want to show active but not actually have the "A" in my report. Can you please show me here what I would do?

    Thank you

    SELECT .GLMASTER.COMPANY, .GLMASTER.ACCT_UNIT, .GLNAMES.DESCRIPTION, .GLMASTER.ACCOUNT, .GLCHARTDTL.ACCOUNT_DESC, .GLNAMES.ACTIVE_STATUS

    FROM (.GLMASTER LEFT JOIN .GLNAMES ON (.GLMASTER.ACCT_UNIT = .GLNAMES.ACCT_UNIT) AND (.GLMASTER.COMPANY = .GLNAMES.COMPANY)) LEFT JOIN .GLCHARTDTL ON .GLMASTER.ACCOUNT = .GLCHARTDTL.ACCOUNT

    WHERE (((.GLMASTER.ACCT_UNIT)<>10002 And (.GLMASTER.ACCT_UNIT)<>10004 And (.GLMASTER.ACCT_UNIT)<>10005 And (.GLMASTER.ACCT_UNIT)<>10006 And (.GLMASTER.ACCT_UNIT)<>10504 And (.GLMASTER.ACCT_UNIT)<>270105 And (.GLMASTER.ACCT_UNIT)<>100101))AND ((GLNAMES.ACTIVE_STATUS)='A');

  • Just remove the column you do not want to see from the SELECT statement

    SELECT.GLMASTER.COMPANY,

    .GLMASTER.ACCT_UNIT,

    .GLNAMES.DESCRIPTION,

    .GLMASTER.ACCOUNT,

    .GLCHARTDTL.ACCOUNT_DESC,

    --REMOVE THIS COLUMN

    .GLNAMES.ACTIVE_STATUS

    FROM (

    .GLMASTER LEFT JOIN.GLNAMES ON (.GLMASTER.ACCT_UNIT =.GLNAMES.ACCT_UNIT)

    AND (.GLMASTER.COMPANY =.GLNAMES.COMPANY)

    )

    LEFT JOIN.GLCHARTDTL ON.GLMASTER.ACCOUNT =.GLCHARTDTL.ACCOUNT

    WHERE (

    (

    (.GLMASTER.ACCT_UNIT) <> 10002

    AND (.GLMASTER.ACCT_UNIT) <> 10004

    AND (.GLMASTER.ACCT_UNIT) <> 10005

    AND (.GLMASTER.ACCT_UNIT) <> 10006

    AND (.GLMASTER.ACCT_UNIT) <> 10504

    AND (.GLMASTER.ACCT_UNIT) <> 270105

    AND (.GLMASTER.ACCT_UNIT) <> 100101

    )

    )

    AND ((GLNAMES.ACTIVE_STATUS) = 'A');

    This is what you want:

    SELECT.GLMASTER.COMPANY,

    .GLMASTER.ACCT_UNIT,

    .GLNAMES.DESCRIPTION,

    .GLMASTER.ACCOUNT,

    .GLCHARTDTL.ACCOUNT_DESC

    FROM (

    .GLMASTER LEFT JOIN.GLNAMES ON (.GLMASTER.ACCT_UNIT =.GLNAMES.ACCT_UNIT)

    AND (.GLMASTER.COMPANY =.GLNAMES.COMPANY)

    )

    LEFT JOIN.GLCHARTDTL ON.GLMASTER.ACCOUNT =.GLCHARTDTL.ACCOUNT

    WHERE (

    (

    (.GLMASTER.ACCT_UNIT) <> 10002

    AND (.GLMASTER.ACCT_UNIT) <> 10004

    AND (.GLMASTER.ACCT_UNIT) <> 10005

    AND (.GLMASTER.ACCT_UNIT) <> 10006

    AND (.GLMASTER.ACCT_UNIT) <> 10504

    AND (.GLMASTER.ACCT_UNIT) <> 270105

    AND (.GLMASTER.ACCT_UNIT) <> 100101

    )

    )

    AND ((GLNAMES.ACTIVE_STATUS) = 'A');

    What is generating this code? Are you typing this into a query window? It appears to be code generated by right clicking on a table, or using "Design Query in Editor" from the menu.

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • DUH!!!! wow what a newb move I made lol. Thank you so much, thats what I needed!!!:w00t:

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply