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"

    Relevant Pages

    • Hard SQL
      ... This SQL returns to me the last 10 records in a table, ... SELECT * FROM suppliers WHERE EXISTS (select * from orders where ... Can I use an Alias? ... Tnks ...
      (microsoft.public.access.queries)
    • Re: Serious errors with Create view command
      ... Either you open each view as needed with a different alias and assign this ... stored in the database, ... Edit Stored Procedures opens a code editing window and saves the code you ... can't paste it INTO the view designer sql view window as that's Read ...
      (microsoft.public.fox.helpwanted)
    • Re: Ranking - dealing with ties
      ... I didn't think until too late just to post the SQL - sorry. ... qryDivScore has fields Score and Div. ... Alias Scor1) ... Alias has to be used instead of the actual query name, ...
      (microsoft.public.access.formscoding)
    • Re: Help - Backup not working after trying to get ISA 2004 to log to SQL
      ... On the Alias tab, ... there was an alias set up that had <servername> as the alias, ... I did a lot of restarting the SQL, WSUS and VSS services, but didn't make ... Backup log file shows this error: ...
      (microsoft.public.windows.server.sbs)
    • Re: Apostrophe in SQL string
      ... The security hole you open up with dynamic sql strings would ... > rights.Please do not send email directly to this alias. ... sometimes there are customers with ...
      (microsoft.public.dotnet.framework.adonet)