1

I use QGIS 2.18.0 on Windows 10.

I wanted to add a layer from PostGIS using the DB Manager. After choosing the "unique column" and the "geometry column" the DB Manager did not load the layer. However, without any error message or hint. The reason why it did not load was that there were columns with the same name (duplicate column names).

Does DB Manager usually tell me about duplicate column names?

(or is this "feature" not implemented?) (or is my QGIS version too old?)

  • Out of curiosity: how did you manage to create a table with two columns with the same names? I don't think that's possible to accomplish in a RDMS. – Michal Zimmermann Jun 30 '17 at 11:09
  • With a join. I finally had two columns named "geom". – coding_bird Jun 30 '17 at 11:14
3

If you're running a query including the JOIN clause, consider renaming the columns in the result set as follows:

SELECT
    a.geom,
    b.geom geom1
FROM a
JOIN b ON (a.id = b.id);

That way you won't have any duplicate column names.

  • Yes, I did this finally. Before I simply did "SELECT * FROM ... " - I just find it strange that DB Manager does not warn me about duplicate columns. It took me while to find out the problem ... – coding_bird Jun 30 '17 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.