1 Reply Latest reply: Dec 5, 2012 10:07 PM by Lav Jain RSS

    JOIN+LOAD and aliases

      Hi there,

       

      I am confronted to a rather trivial scripting problem in QV.

       

      For the need of a calculated field, I want to join two QV tables, aliased Alias1 and Alias2 below.

       

      [Alias1]:
      SQL SELECT ... FROM ...;
      
      [Alias2]:
      SQL SELECT ... FROM ...;
      
      

       

      A JOIN come to the rescue to achieve just that:

       

      [Alias3]:
      INNER JOIN ([Alias2])
      LOAD * RESIDENT [Alias1];
      
      DROP TABLE [Alias1];
      

       

      I like the idea of having a seperate QV object that lets me join two existing resident tables.

       

      However, what happens in the Table Viewer is the joined fields (Alias1') are added to Alias2, and added fields are prepended with the string "Alias3". I understand the JOIN is actually effective in Alias2, explaining why I cannot drop Alias2.

       

      Besides doing:

       

      [Alias3]:
      INNER JOIN (SQL SELECT ... FROM ...)
      LOAD * SQL SELECT ... FROM ...;];
      

       

      Is there any way around this? The concern again is to keep two separate entities (with their own SQL queries), that are later joined, and loaded in a new table.

        • Re: JOIN+LOAD and aliases
          Lav Jain

          just remove the table name [Alias3] and only use:

           

          [Alias1]:
          SQL SELECT ... FROM ...;

          [Alias2]:
          SQL SELECT ... FROM ...;

           

           

          INNER JOIN ([Alias2])
          LOAD * RESIDENT [Alias1];

          DROP TABLE [Alias1];

           

           

          Now if u want to rename table Alias2, u can use: Rename table Alias 2 to Alias3

           

           

           

          Regards