IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to code not equal to in SQL query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sarva_bubli

New User


Joined: 09 Aug 2006
Posts: 37
Location: Pune, India

PostPosted: Mon Dec 04, 2006 1:17 am
Reply with quote

Hi,
How to code not equal to in SQL query.....
May I have the explanation....
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Mon Dec 04, 2006 3:38 am
Reply with quote

Read the SQL reference manual, first.

Does this request "an explanation"?? !! Semantic?
Back to top
View user's profile Send private message
Madhu Reddy

New User


Joined: 28 Sep 2006
Posts: 56

PostPosted: Mon Dec 04, 2006 9:35 am
Reply with quote

we need to code as not equal to

for example

select * from table where column1 not equal to zero.

as query please reply
Back to top
View user's profile Send private message
Sarva_bubli

New User


Joined: 09 Aug 2006
Posts: 37
Location: Pune, India

PostPosted: Wed Dec 06, 2006 7:14 pm
Reply with quote

Hi Madhu,
I got the answer. For example select Ac number from Cust table
EXEC SQL
SELECT ACCT_NO
INTO :EOP675ACCT-NO,
FROM EOP_AC_TABL
WHERE CUST_NO = XXXXXXXX
AND WIP-ID ? = 'D'
END-EXEC

Here WIP-ID not = 'D'. The not ( ? )symbol can be given as such.

Correct me if I'm wrong.
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Wed Dec 06, 2006 10:07 pm
Reply with quote

One more way of using NOT EQUAL is by using '<>'

Code:

WHERE ACCT_ID <> ' '

Back to top
View user's profile Send private message
Sarva_bubli

New User


Joined: 09 Aug 2006
Posts: 37
Location: Pune, India

PostPosted: Thu Dec 07, 2006 12:02 pm
Reply with quote

Hi MFRASHEED,
Let me try with this way also. Thanks for the info.
Back to top
View user's profile Send private message
h.dinesh

New User


Joined: 06 Dec 2006
Posts: 46
Location: Chennai

PostPosted: Thu Dec 07, 2006 2:38 pm
Reply with quote

Both <> and ?= is working but 'not equal to' is not working
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Fri Dec 08, 2006 6:17 am
Reply with quote

DB2 V8 doesn't support "?" character, so a good idea to use "<>".
Back to top
View user's profile Send private message
Sarva_bubli

New User


Joined: 09 Aug 2006
Posts: 37
Location: Pune, India

PostPosted: Mon Dec 11, 2006 7:32 pm
Reply with quote

Hi Dinesh & Priyesh,
thanks for the response..
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Dec 12, 2006 4:18 am
Reply with quote

One additional consideration when coding not equal ?<>? is that if you are tying to compare against a null, you will not get a ?true? condition. Therefore you will need to code as follows:

Code:

WHERE COL_1 <> ?ABC?
   OR COL-1 IS NULL


Dave
Back to top
View user's profile Send private message
Sarva_bubli

New User


Joined: 09 Aug 2006
Posts: 37
Location: Pune, India

PostPosted: Fri Dec 15, 2006 9:42 am
Reply with quote

Hi Dave,
Thanks for the additional info.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts purge jobs with return code 0 and ret... JCL & VSAM 4
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 0
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top