<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div>On Jan 24, 2012, at 1:29 PM, Moritz Lennert wrote:</div></span></div><div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On 24/01/12 19:49, Kirk Wythers wrote:<br><blockquote type="cite">I am trying to do a 'join' of a column from one table, to the attribute table of another vector. However, I am getting an error about a problem adding another column due to a duplicate column name.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Snip of commands are below:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">GRASS 6.4.1 (latlon):~&gt; &nbsp;v.info -c ew4kmg<br></blockquote><blockquote type="cite">Displaying column types/names for database connection of layer 1:<br></blockquote><blockquote type="cite">INTEGER|cat<br></blockquote><blockquote type="cite">INTEGER|Id<br></blockquote><blockquote type="cite">DOUBLE PRECISION|XMIN<br></blockquote><blockquote type="cite">DOUBLE PRECISION|XMAX<br></blockquote><blockquote type="cite">DOUBLE PRECISION|YMIN<br></blockquote><blockquote type="cite">DOUBLE PRECISION|YMAX<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">GRASS 6.4.1 (latlon):~&gt; &nbsp;db.describe -c ew4km_tawc<br></blockquote><blockquote type="cite">ncols: 13<br></blockquote><blockquote type="cite">nrows: 265090<br></blockquote><blockquote type="cite">Column 1: ID:INTEGER:20<br></blockquote><blockquote type="cite">Column 2: COUNT:INTEGER:20<br></blockquote><blockquote type="cite">Column 3: AREA:DOUBLE PRECISION:20<br></blockquote><blockquote type="cite">Column 4: MIN:INTEGER:20<br></blockquote><blockquote type="cite">Column 5: MAX:INTEGER:20<br></blockquote><blockquote type="cite">Column 6: RANGE:INTEGER:20<br></blockquote><blockquote type="cite">Column 7: MEAN:DOUBLE PRECISION:20<br></blockquote><blockquote type="cite">Column 8: STD:DOUBLE PRECISION:20<br></blockquote><blockquote type="cite">Column 9: SUM:DOUBLE PRECISION:20<br></blockquote><blockquote type="cite">Column 10: VARIETY:INTEGER:20<br></blockquote><blockquote type="cite">Column 11: MAJORITY:INTEGER:20<br></blockquote><blockquote type="cite">Column 12: MINORITY:INTEGER:20<br></blockquote><blockquote type="cite">Column 13: MEDIAN:INTEGER:20<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">GRASS 6.4.1 (latlon):~&gt; &nbsp;v.db.select ew4kmg | head -7<br></blockquote><blockquote type="cite">cat|Id|XMIN|XMAX|YMIN|YMAX<br></blockquote><blockquote type="cite">1|128|-1793092|-1789092|-1142894|-1138894<br></blockquote><blockquote type="cite">2|129|-1793092|-1789092|-1138894|-1134894<br></blockquote><blockquote type="cite">3|130|-1793092|-1789092|-1134894|-1130894<br></blockquote><blockquote type="cite">4|826|-1789092|-1785092|-1150894|-1146894<br></blockquote><blockquote type="cite">5|827|-1789092|-1785092|-1146894|-1142894<br></blockquote><blockquote type="cite">6|828|-1789092|-1785092|-1142894|-1138894<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">GRASS 6.4.1 (latlon):~&gt; &nbsp;db.select ew4km_tawc | head -7<br></blockquote><blockquote type="cite">ID|COUNT|AREA|MIN|MAX|RANGE|MEAN|STD|SUM|VARIETY|MAJORITY|MINORITY|MEDIAN<br></blockquote><blockquote type="cite">127|349|314100|2163|2850|687|2199.68|131.842|767687|36|2163|2185|2163<br></blockquote><blockquote type="cite">128|7906|7115400|932|2850|1918|2182.34|534.089|17253600|252|2762|1245|2202<br></blockquote><blockquote type="cite">129|10528|9475200|864|2762|1898|1733.46|877.929|18249900|3|864|1568|1568<br></blockquote><blockquote type="cite">130|15421|13878900|539|2850|2311|1403.27|806.156|21639900|80|864|539|864<br></blockquote><blockquote type="cite">131|17822|16039800|864|2762|1898|1024.77|111.876|18263400|3|1096|2762|1096<br></blockquote><blockquote type="cite">132|17689|15920100|864|1096|232|1076.65|64.1395|19044900|2|1096|864|1096<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">So I am trying to perform the join the MEAN column in the table ew4km_tawc on the Id column in the map ew4kmg. Here is the output:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">GRASS 6.4.1 (latlon):~&gt; &nbsp;v.db.join map=ew4kmg column=Id otable=ew4km_tawc ocolumn=MEAN<br></blockquote><blockquote type="cite">DBMI-SQLite driver error:<br></blockquote><blockquote type="cite">Error in sqlite3_prepare():<br></blockquote><blockquote type="cite">duplicate column name: ID<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">ERROR: Error while executing: 'ALTER TABLE ew4kmg ADD COLUMN ID INTEGER<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'<br></blockquote><blockquote type="cite">ERROR: Cannot continue (problem adding column).<br></blockquote><blockquote type="cite">ERROR: Cannot continue.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I am confused since it seems to me, that there has to be a duplicate column name (in this case 'ID', in order for the join to know what to join on… Any suggestions would be much appreciated!<br></blockquote><br>No, there has to be two columns containing the join criterium, but these do not have to have the same column name. As you can see from the error, they actually shouldn't have the same name (note: the module should probably just prefix each column with the name of the original table to avoid such issues...but then you run into column name length issues.).<br><br>You v.db.join is incorrect as well, as your ocolumn is ID, not MEAN. the column and ocolumn options designate the respective columns in the two tables that contain the join criterium. All of the other columns of otable will be joined to the table of your vector map.<br><br></div></blockquote><br></div><div>Thanks Moritz,</div><div><br></div><div>I just want to make sure I understand your point… &nbsp;</div><div><br></div><div>I want to attach the "MEAN" from the table "ew4km_tawc" added to the vector map "ew4kmg" where ew4kmg_Id is the same as ew4km_tawc_ID, so you are saying that my join needs to be:</div><div><br></div><div>v.db.join ew4kmg col=Id otable=ew4km_tawc ocol=ID?</div><div><br></div><br></body></html>