[GIS] Parameterizing SQL Views Geoserver

geoserverparameterssql

I must do a view in geoserver. I seen some example here: http://docs.geoserver.org/stable/en/user/data/database/sqlview.html. The example show the operator like for parameterizing view. Suppose, now that in WFS request there is a value for a field (named filed1) example &viewparams=value1:a. If i use the operator like

Select filed1, filed2, field3       
From  myTable 
where  field1 like %value1% 

the view return tuples where filed1 is a, aa, aaa, aaaa, aaaaa, etc, but i want tuples where filed1='a'. Can i use the operator =, if yes how write my query?

Select filed1, filed2, field3       
From  myTable 
where  field1 = .......

Best Answer

From the page you link to:

Within the SQL View query, parameter names are delimited by leading and trailing % signs. The parameters can occur anywhere within the query text, including such uses as within SQL string constants, in place of SQL keywords, or representing entire SQL clauses.

So I suspect you can do:

Select filed1, filed2, field3       
From  myTable 
where  field1 = %value1%