Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Using aliases in MYSQL

  1. Jul 26, 2013 #1
    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?
     
  2. jcsd
  3. Jul 26, 2013 #2
    Not that I am aware of.
     
  4. Jul 26, 2013 #3

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    The database does not store aliases you used in some query.

    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'")
     
  5. Jul 26, 2013 #4

    DavidSnider

    User Avatar
    Gold Member

    If you have some good reason for having external (global) aliases to columns or tables then you can create a view
     
    Last edited: Jul 26, 2013
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Using aliases in MYSQL
  1. Help with MySQL (Replies: 3)

  2. IP aliases and WAN (Replies: 3)

Loading...