corbin Posted February 22, 2008 Share Posted February 22, 2008 Hello.... I'm trying to do: SELECT col1, (CASE WHEN col2 = 1 THEN col5 WHEN col2 = 2 THEN col6) var1 FROM table1 t WHERE col3 IN (SELECT DISTINCT col1 FROM table2 WHERE col2 = var1) (Obviously replaced with bogus names ;p) Anyway, I need to know if that's possible, and if it is, what the syntax is as that gives an error. Thanks, -Corbin Quote Link to comment https://forums.phpfreaks.com/topic/92386-alias-inside-of-subquery/ Share on other sites More sharing options...
corbin Posted February 22, 2008 Author Share Posted February 22, 2008 Blerh can't edit.... Anyway, I realized I could do: SELECT col1, (CASE WHEN col2 = 1 THEN col5 WHEN col2 = 2 THEN col6) var1 FROM table1 t WHERE col3 IN (SELECT DISTINCT col1 FROM table2 WHERE col2 = (CASE WHEN t1.col2 = 1 THEN t1.col5 WHEN t1.col2 = 2 THEN t1.col6)) Quote Link to comment https://forums.phpfreaks.com/topic/92386-alias-inside-of-subquery/#findComment-473393 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.