reference column name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thesti
    New Member
    • Nov 2007
    • 144

    reference column name

    hi,

    how to reference an alias column name that consists more than one word.

    it's like this

    select address, substring(addre ss, 5, 8) as 'member's address' from msmember
    where charindex('r', substring( alias column name, 1, 6))>0

    i want to check if the first 6 chars of 'member's address' contains 'r'.


    thx.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by thesti
    hi,

    how to reference an alias column name that consists more than one word.

    it's like this

    select address, substring(addre ss, 5, 8) as 'member's address' from msmember
    where charindex('r', substring( alias column name, 1, 6))>0

    i want to check if the first 6 chars of 'member's address' contains 'r'.


    thx.

    I don't think you're allowed to have quote in a column alias.

    Try this instead:

    Code:
    select address, substring(address,5,8) as [member address] from msmember where charindex('r', left(address,6)) > 0
    Watch out for space on the left side of the address field.

    -- CK

    Comment

    Working...