• RP_DBA (2/23/2011)


    How about if you moved the email criteria to the outer select and added a DISTINCT?

    insert into userprofile(userID, fieldID, value,)

    select distinct userID, 1000, 'external'

    from user

    where not exists (

    select userID

    from userprofile

    where userid = user.userid

    and fieldID = '1000')

    and (user.email LIKE '%@hotmail%' or

    user.email LIKE '%@gmail%' or

    user.email LIKE '%@googlemail%' or

    user.email LIKE '%@yahoo%')

    Thanks Nate. Just what I was looking for.