So I have to bring up this old question How to join a WFS layer to a stand-alone table in OpenLayers

I recently have to get this working, I have to join a WFS layer data from GeoServer using postgis store. The WFS data will contain key attribute and the table data will also contain key attribute that will became the join key.

The table will be an exported result of MySQL database, so it is impossible for me to join on server side.

So how do I join it on client side?

I have an alternative approach that is export from MySQL then import to PostgreSQL/PostGIS and join in PGSQL, but I dont't think this a good way.

  • I think you need to provide a little more detail. What is the data structure of the exported table? (JSON, HTML, etc) and then how exactly do you need to join the two? Do you want to click the feature on the map and show the data from the table? Do you want to click a row in the table and highlight the corresponding feature on the map?
    – CHenderson
    Apr 30, 2015 at 23:58
  • I'm thinking the data would be JSON, or any other type is okay as long there's an example how to. And I would use it as both your options, plus label the feature and style by attribute.
    – Zery
    May 1, 2015 at 0:53

1 Answer 1


You could for example use jquery Datatables ( www.datatables.net ) and create the data-structure on the server-side with php: https://www.datatables.net/examples/server_side/

Then load this data dynamically in your datatable.

If you have a common key you could even synchronize the select-control of openlayers with the datatable.

You can have a look at one of my jsfiddles:


There I request a WFS-Service and build the attribute-table dynamically. Perhaps this helps you to get an idea of how you can do your join between the mysql-data and the postgis-data.

One other nice option could be to use a Foreign Data Wrapper ( https://wiki.postgresql.org/wiki/Foreign_data_wrappers ) so you could access your mysql-tables from "within" postgresql and do an "up to date" join there.

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.