Using JOIN for querying
cris ricana
crisricana at GMAIL.COM
Wed Aug 30 23:43:42 PDT 2006
Hi!
> here is a last+1 try:
> You mentioned the template file: On umn.mapserver.ch I found this example:
>
> LAYER
> NAME "Liegenschaften"
> STATUS ON
> DATA "data/Liegenschaften"
> TYPE LINE
> HEADER "NUMMER FLAECHE NAME PLZ ORT"
> JOIN
> NAME "Eigentümer"
> TABLE "data/eigentuemer.dbf"
> FROM NUMMER
> TO NR
> TYPE multiple
> TEMPLATE eigentuemer.htm
> END
> CLASS
> COLOR 0 0 0
> SYMBOL "continue"
> SIZE 2
> TEMPLATE liegenschaften.htm
> END
> END
>
> Here are two template files. The Layer has a template file in his own
> CLASS Section. Is your mapfile analog to this file?
>
> Manfred
Thank you very much Manfred! Because of your suggestion, I think I got
the answer to this problem.
When you emailed me the JOIN example above, it got me thinking if its
actually my mapfile that was wrong. My mapfile is actually correct as
I compare it with the example, as well as the template file, so
perhaps I made a mistake in the main html that gives the query option.
Sure enough, I made the mistake of using the name of the join as the
layer name. I realize now that even if we join two dataset, the
resulting join do not exist as a new layer (i.e.. as something we can
call and use) but more or less as an extension of the old layer. I
think this is true for other kind of datasets, dbfs and csvs. I also
want to try JOIN using direct mysql access, but got the following
error:
Content-type: text/html msMySQLJoinConnect(): Query error. MySQL
support not available (compile with --with-mygis)
Which is what I expect since I didn't compile mapserver with using
MySQL in mind. Anyway here's my JOIN statement if you're interested,
Greg:
(...)
JOIN
CONNECTIONTYPE mysql
CONNECTION "localhost:root::LGU"
# The syntax is
# CONNECTION "<hostname>:<username>:<password>:<database>"
TABLE "lgu_DB_DHDPSEX"
FROM "Place_ID"
NAME "reg_join"
TO "PLACE_ID"
TYPE single
TEMPLATE "reg_bndary2000_dbf.html"
END #join
In the template file where the results should show, use the format
"[<join_name>_<fieldname>]" for dbf and mysql joins and
"[<join_name>_<fieldname>]" for csv joins. For example, I'm using
[reg_join_2] to access data from the 2nd column of my csv file.
Please tell me what happens if you try it, Greg.
Maricris
More information about the MapServer-users
mailing list