File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes How to Use Condition in SQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to Use Condition in SQL" Watch "How to Use Condition in SQL" New topic
Author

How to Use Condition in SQL

Dhiraj Srivastava
Ranch Hand

Joined: Aug 29, 2001
Posts: 49
Hi,

Here this query gives location of first occurance of letter 'A' in the name.

select
(posstr(t1.NAME,'A')) as Location, t1.Name from vista.VFZPVACCOUNTANT t1


------------ OUTPUT ------------------

LOCATION NAME
----------- --------------------------
0 test
14 Kuhn Handels AG

-------------------------------------
-------------------------------------

I want to select only "Non Zero" location records. Means There should be atleast one 'A' or 'a' in the name.

So that in the output there should be only second record.

I am working on Db2 database Can ne one help.

Thanks in advance,
Dhiraj Srivastava
Mukhtiar Ahmed
Greenhorn

Joined: Jun 27, 2007
Posts: 7
Hi,
Please user where clause in your query

select
(posstr(t1.NAME,'A')) as Location, t1.Name from vista.VFZPVACCOUNTANT t1

where Location > 0
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38851
    
  23
Surely you mean

. . . WHERE location >= 0

?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Use Condition in SQL