arianhojat Posted April 5, 2007 Share Posted April 5, 2007 i was wondering... it seems an alias from an outer Query being used in an inner one doesnt work in MYSQL5. heres a quick example: SELECT * FROM db.test1 t1 JOIN ( SELECT t2. FROM db.test2 t2 WHERE t2.age=t1.age ) as xxx ON t1.ID=xxx.ID MYSQL will say something like unknown column 't1.age' in where clause since i think u cant have table aliases in WHERE clauses, so how do you target that field? i think my orig query had 2 outer joins, so there would be 2 age fields to use in the inner query, so i needed to somehow target it and an alias doesnt work. any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/45739-mysql-subquery-aliases/ Share on other sites More sharing options...
gluck Posted April 5, 2007 Share Posted April 5, 2007 What are you trying to achieve here? Table 1 joining a join of Table1 and Table 2? Describe the problem and I might be able to help you out. Quote Link to comment https://forums.phpfreaks.com/topic/45739-mysql-subquery-aliases/#findComment-222248 Share on other sites More sharing options...
Barand Posted April 5, 2007 Share Posted April 5, 2007 SELECT t1.*, t2.age as age2 FROM test1 t1 INNER JOIN test2 t2 ON t1.ID = t2.ID AND t1.age = t2.age Quote Link to comment https://forums.phpfreaks.com/topic/45739-mysql-subquery-aliases/#findComment-222300 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.