MySQL: Using Aliases & Old Names

  • Thread starter Thread starter EdmureTully
  • Start date Start date
  • Tags Tags
    Mysql
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 2K views
EdmureTully
Messages
20
Reaction score
0
If you rename an attribute or a relation with the keyword AS in MYSQL can you use the alias created outside the query where you renamed the attribute, also can you use the old name?
 
Physics news on Phys.org
EdmureTully said:
If you rename an attribute or a relation with the keyword AS in MYSQL can you use the alias created outside the query where you renamed the attribute, also can you use the old name?

Not that I am aware of.
 
The database does not store aliases you used in some query.

also can you use the old name?
Interesting, I never tried that. It is not possible.

SELECT * FROM `tablename` AS t WHERE t.fieldname=1 -> works
SELECT * FROM `tablename` WHERE tablename.fieldname=1 -> works
SELECT * FROM `tablename` AS t WHERE tablename.fieldname=1 -> does not work ("Unknown column 'tablename.fieldname' in 'where clause'")
 
If you have some good reason for having external (global) aliases to columns or tables then you can create a view
 
Last edited: