my dog learned polymorphism*
The moose likes JDBC and the fly likes Can i search for item by giving three items to compare in the query? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Can i search for item by giving three items to compare in the query? " Watch "Can i search for item by giving three items to compare in the query? " New topic
Author

Can i search for item by giving three items to compare in the query?

Yuta Lolap
Ranch Hand

Joined: Jun 03, 2012
Posts: 80

Hello all,

I am trying to search for the cust id based on these three constraints. Will it work? Is it ok to use three columns to compare data?

"select cust id from customers where fname = ? and lname = ? and flatno = ?";

Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

This looks like an ordinary parametrized query. I don't see anything ORM related here, so I am moving it to the JDBC forums. You can add as many restrictions as you would like in your where clause. However having a space in cust id looks suspect.


[How To Ask Questions][Read before you PM me]
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1106

the column cust id will need around it if it really does have a space in the column name.

what you entered is valid sql and whether it is good enough depends on your data, for example many families name the first son after the father so will have 2 arthur smiths living in flat 4b.
 
 
subject: Can i search for item by giving three items to compare in the query?
 
Similar Threads
question of useBean
jsp:useBean tag question in mock exam
Will this locking mechanism be allowed?
mistake in assesment exam?
Bad answer in question in Sun preparation exam