NocFenix
NocFenix

Reputation: 701

Ignore Column in SQL Select

Here is my select statement:

SELECT DISTINCT
    ms.createdon
    ,c.new_memberid
    ,c.firstname
    ,c.lastname
    ,c.new_primaryclubname
    ,a.line1
    ,a.city
    ,a.stateorprovince
    ,a.postalcode
    ,c.telephone1
    ,c.telephone2
    ,c.birthdate
    ,c.gendercodename
    ,p.ProductNumber
    ,mr.new_backgroundcheckflagname
    ,c.emailaddress1
    ,c.new_divisioncode
    ,c.emailaddress2
FROM
    Filterednew_membershiprequirement AS mr
    LEFT JOIN Filteredcontact AS c ON mr.new_contact = c.contactid
    LEFT JOIN FilteredCustomerAddress AS a ON c.contactid = a.parentid
    INNER JOIN Filterednew_membership AS ms ON c.contactid = ms.new_contact
    INNER JOIN Product AS p ON ms.new_product = p.ProductId
WHERE
    c.new_divisioncode = 'I' AND c.new_memberid= '123465789'

I have a column on the Filterednew_membership that is causing me issues because it has an autonumber that means every time it gets used, it will have a unique identifier, even when every other data-field is the same. How can I tell SQL to ignore this column in order to give me the other fields as just one row instead of multiple ones?

So I'm getting:

CreatedOn | MemberId | Full Name | ProductNum | EVILUNIQUEID
-------------------------------------------------------
01/01/01  | 12345678 | Bobb Ross | 10000      | 1
01/01/01  | 12345678 | Bobb Ross | 10000      | 2
01/01/01  | 12345678 | Bobb Ross | 10000      | 3
01/01/01  | 12345678 | Bobb Ross | 10001      | 4

And what I want is:

CreatedOn | MemberId | Full Name | ProductNum
---------------------------------------------
01/01/01  | 12345678 | Bobb Ross | 10000 
01/01/01  | 12345678 | Bobb Ross | 10001 

Upvotes: 0

Views: 375

Answers (1)

Pavel Gatnar
Pavel Gatnar

Reputation: 4053

Just remove the column name from the select clause.

Upvotes: 1

Related Questions