This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
How do people implement those searches that ask for min and max values? I can do the sql for between. But the problem comes when 1 field is left blank. 1 null spoils the whole equation. How do you handle something like this SELECT * FROM table WHERE name BETWEEN x AND y; What happens when x is null, or y is null? Do I have to have 3 sql statements? 1 for each possibility? THis is a common search so I assume this problem has been solved. Whats the answer?? Thanks!
SELECT * FROM table where ((x = '') OR (x <> '' AND firstName >= x)) AND ((y = '') OR (y <> '' AND firstName <= y)) AND etc... I shouldn't use null values, just use empty strings. That's probably why everyone that answered the question answered as you did.
Joined: Jan 30, 2000
You understand that x and y are the variables the user is entering? Well no, I wasn't really sure about that, or if the statement would be legal if that were the case - just trying ideas. Glad to see something vaguely similar worked out...