Tuesday, 15 September 2015

mysql - Groovy - Joining two SQL Select results -


Before anything is understood, I will just leave you with me (a summary):

RowsTable1 (this is the result of a selection, there are x rows with the Y column)

RowsTable2 (This is the result of a selection in it, there are W rows with Z column in it)

< P> What do I want to insert in each row, line 1 row, one line from rows 2, but I do not have to use rowsTable2 as Pt Need to filter Tion is I \ 'rowsTable1.

For example, in rowsTable1, I have an element called superdid and the second is called ultraid, and rows 2 also have those elements, and this is what I need to merge both rows. it occurs.

My question is, how can I get the only line to filter the rows?

  Enable Rows 1. Ishvindindex {rowT1, i - & gt; Line 1 and lieutenant; & Lt;  

It seems that you collect "to create an overall map" Do ", because I do not think you will be allowed to make changes in the list of rows that came back from the SQL query.

Here is a sample that you should do:

  // If we start with this data (show what this happened back to your questions) def linesTable 1 = [[SuperID: 1, UltraID: 2, C: 'A1b2'], [SuperID: 1, UltraID: 3, C: 'A1B3']] def linesTable 2 = [[Superand: 1] , [AID: 3, D: 'A1 B3Astra'], [SuperID: 3, UltraID: 4, D: 'Around'], [SuperID: 1, Ultride: 2, D: 'A1B2Idestra' ]] // Now, in rows Join for a list of new "row-like" maps where superend and ultride are similar to DEF RATE = ROUTETABLE 1 COLLECT {T1row - & gt; [:] & Lt; & Lt; T1row & lt; & Lt; RowsTable2.find {it.superID == T1row.superID & amp; Amp; It should now be a list of maps in retaining it.ultraid == T1row.ultraID}}  

, each of which contains "merged" row data for all unique combinations of SuperID and UltraData Is rowsTable1 Note that any data in rowsTable2 which is not a SuperEd / UltraDD Combo present in rowsTable1 is ignored, and that all the combos in the rows should be present in 1 row.


No comments:

Post a Comment