Yes it's possible.
Starting with GeoServer 2.1.0 the user can also create a new layer by
specifying a raw SQL query
You can create SQL Views which reference the same table using SQL Statements.
Instructions and Documentation
Update Per OpenLayers question in comment:
It really depends on how you want to serve out your data which depends on what kind and how much data you have.
If the data is vector data and not more than +-300 features you can use WFS. Add that layer like so:
OpenLayers GeoServer WFS Layer Example
If the data is Raster data or you just want your layer served out as an image rather than vector features, then add that layer using WMS. Like so:
OpenLayers WMS Layer Example
Update #2:
Based on your latest comment, what you can do is: add multiple wfs layers to your open layers map which point to ONE layer on your GeoServer but have a filter defined so you only get ONE feature back based on ID or some other attribute in your filter.
Take a look at this example.
Basically it will be something like:
var wfs = new OpenLayers.Layer.Vector("WFS", {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.WFS({
url: "http://demo.opengeo.org/geoserver/wfs",
featureType: "tasmania_roads",
featureNS: "http://www.openplans.org/topp"
}),
filter: new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.And,
filters: [
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "id",
value: "POLYGONID"
})
]
})
});
Simply add the attribute to the feature before the wfs-commit:
// feat is the feature with the area the user drawn
feat.attributes.INVADED_BY_ARMY_ID = 42;
Of course, you should save somewhere the army id...
Best Answer
With a bit of comparison you can:
see: http://jsfiddle.net/XfEmn/
(note, I use underscore.js _.min function, you could of course do this with a foor loop etc, the clue is to loop the features and get the one with the shortest distanceTo the clicked point)