Hard SQL

From: Carlos Durán Urenda (carlos_urenda_at_hotmail.com)
Date: 02/11/05

  • Next message: Jeroen van Kalken: "Re: Hard SQL"
    Date: Fri, 11 Feb 2005 17:38:05 -0600
    
    

    Hi

    This SQL returns to me the last 10 records in a table, order by Id field

            SELECT * FROM MyTable WHERE Id IN ( SELECT TOP 10 Id FROM Table
    ORDER BY Id DESC) ORDER BY Id

    But i need to get a similar result based in two o more id Fields

    can I to do it with the EXISTS Statment?, I found this example...
    SELECT * FROM suppliers WHERE EXISTS (select * from orders where
    suppliers.supplier_id = orders.supplier_id);

    But how can i do to apply it to the same table?

    Can I use an Alias?

    Can someone say to me how to do it?

    Tnks


  • Next message: Jeroen van Kalken: "Re: Hard SQL"