aspose file tools*
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
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: 83

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: 1680
    
    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: 1107

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.
 
jQuery in Action, 2nd edition
 
subject: Can i search for item by giving three items to compare in the query?