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?)

2
  • 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. Jun 30, 2017 at 11:09
  • With a join. I finally had two columns named "geom". Jun 30, 2017 at 11:14

1 Answer 1

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.

1
  • 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 ... Jun 30, 2017 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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