Forums Register Login

How to Exclude one record from Query?

+Pie Number of slices to send: Send
Hello Ranchers,

I have a current search By Name for users form, It's working just fine.

What I would to do is to exclude one of my result to be showed up

Let say I have this table,

FName LName Address
Samar Land WI
Matt Lero WI
Dany Land WI

When I do search for land, the normal results it will be Samar & Dany
Or If I do Dany, result will be Dany Land

What I want is not displaying Dany at all in my result.

So, What it comes to my mind, that I can add as an if statement in JSP page for



it didn't work like this way, Any other suggestions to make it here?
+Pie Number of slices to send: Send
You're doing it backwards. If you don't want certain records to display, don't fetch them from the database in the first place. Use a where clause on your query to filter the results to only those that will be displayed.

The JSTL in the JSP is most certainly not the place to be doing this.
+Pie Number of slices to send: Send
I'm looking for a way without modify my query.
+Pie Number of slices to send: Send
Why? It's the right way to do it.
1
+Pie Number of slices to send: Send
I noticed that your commented out <c:if> statement was invalid.

Instead of
Try

The EL expression should be the whole expression, including the static string value.

I would echo Bear in saying that it would be preferable to do the filtering in java code - either in your query, or whatever code is processing the results of the query to put it into your user list.
+Pie Number of slices to send: Send
Yes, failing doing it in the query (as is appropriate), then at minimum it should be handled in model or controller code. The view is no place to be doing this sort of thing.
1
+Pie Number of slices to send: Send
I solved it by adding this to my query.

1
+Pie Number of slices to send: Send
Good to see that you are dealing with it at the query level. But that seems rather specific. Have you considered what would be needed if the excluded string where to change? Or if you needed to exclude on multiple strings? You might want to investigate the "in" clause.
+Pie Number of slices to send: Send
What I figured out to do so far here is adding a properties file with the exclude list, then add it to my query

exempt.properties
students =Samar,Dan

Then I had to add the following to my query:

Add the method:


Hope that will help the others

I think the title of my thread should be changed.
+Pie Number of slices to send: Send
 

Samar Land wrote:I think the title of my thread should be changed.


What would you suggest?
+Pie Number of slices to send: Send
 

Bear Bibeault wrote:

Samar Land wrote:I think the title of my thread should be changed.


What would you suggest?



Maybe something like:

How to Exclude one record from Query?
Everybody's invited. Except this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1117 times.
Similar Threads
Acess list elements on foreach JSTL tag
Help accessing data in a List of Maps
Passing row id from html table on jsp to Action Class in Struts
Spring form submit
Pass JSTL data via Javascript
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 03:30:07.