Can I use the same alias for different tables within one store procedure?

  • Can I use the same alias for different tables within one store procedure? For example, does code below create an error?

    select * from Order o inner join Customer c on c.orderid = o.orderid

    select * from OrderHistory o inner join Customer c on c.orderid = o.orderid

    Both tables, Order and OrderHistory are using the same alias o, is it ok?

  • that's fine

    ______________________________________________________________________________________________
    Forum posting etiquette.[/url] Get your answers faster.

  • the rule of thumb is each object in a statement must be uniquely identifyable, whether by object name or by alias;

    in your example, each sql is standalone and following the rules just fine.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Hi

    There will not be problem in your query defiantly it will work, Better keep alias separately so that your code may look gud

    Note: You can also have or use same alias name

    Thanks

    Parthi

    Thanks
    Parthi

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply