This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes JDBC and Relational Databases 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


Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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: 44449
    
  34
Surely you mean

. . . WHERE location >= 0

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