Jump to content

MYSQL Subquery aliases


arianhojat

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/45739-mysql-subquery-aliases/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.