Skip to main content
Inspiring
June 8, 2009
Question

Right() in Subquery

  • June 8, 2009
  • 1 reply
  • 585 views

Is it possible to use Right() in a subquery? If so, how is it done? The following attempt at writing the query does not work...

This does NOT work:

select *,
                 (select user_type_description from user_types where user_type_id LIKE 'right(uts.user_type_id, 2)%' and user_type_description LIKE '%(Header)') as col
             from users_types uts, user_types ut
             where uts.user_type_id *= ut.user_type_id
             and uts.edcom_id = 592
             order by uts.display_order asc

This does work though:

select *,
                 (select user_type_description from user_types where user_type_id LIKE '11%' and user_type_description LIKE '%(Header)') as col
             from users_types uts, user_types ut
             where uts.user_type_id *= ut.user_type_id
             and uts.edcom_id =592
             order by uts.display_order asc

Thank you for the help

This topic has been closed for replies.

1 reply

jbreslowAuthor
Inspiring
June 8, 2009

Love it when I get to answer my own questions

select *,uts.user_type_id, left(uts.user_type_id, 2) as col2,
    (select top 1 user_type_description from user_types where user_type_id LIKE left(uts.user_type_id, 2)+ '%') as col
from users_types uts, user_types ut
where uts.user_type_id *= ut.user_type_id
and uts.edcom_id = 592
order by uts.display_order asc