Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear sir

How do i check not equal conditon for where?

my code
SQL
$q1=("SELECT kismispurchase.km_id, kismispurchase.kpm_id,kismispurchase.lot_no as lot_no, kismispurchasemaster.Sdate as sdate FROM kismispurchase inner join kismispurchasemaster on kismispurchasemaster.kpm_id=kismispurchase.kpm_id and where kismispurchase.availableqty!=0;


please help..
Posted
Updated 5-Jul-14 3:18am
v2
Comments
[no name] 5-Jul-14 8:53am    
<>

if kismispurchase.availableqty contains NULL value also then write in below way

isnull(kismispurchase.availableqty,0) <> 0 or also isnull(kismispurchase.availableqty,0) != 0
 
Share this answer
 
Comments
CHill60 5-Jul-14 10:53am    
Good point about the NULL value, but that second statement is wrong ... != is not valid. You might want to remove it
CHill60 6-Jul-14 20:36pm    
I stand corrected about the "!=" ... that will teach me to use a more modern version of SQL Server. My apologies
change
and where kismispurchase.availableqty!=0

to
where kismispurchase.availableqty <> 0
 
Share this answer
 
hello....

your NOT Equal Condition Is Correct...you Can Use both Symblos

(!=,<>)

May be your Column "kismispurchase.availableqty" Contains null value than your query not return correct data so you can use ISNULL like this



$q1=("SELECT kismispurchase.km_id, kismispurchase.kpm_id,kismispurchase.lot_no as lot_no, kismispurchasemaster.Sdate as sdate FROM kismispurchase inner join kismispurchasemaster on kismispurchasemaster.kpm_id=kismispurchase.kpm_id and where isnull(kismispurchase.availableqty,0)!=0");

OR
$q1=("SELECT kismispurchase.km_id, kismispurchase.kpm_id,kismispurchase.lot_no as lot_no, kismispurchasemaster.Sdate as sdate FROM kismispurchase inner join kismispurchasemaster on kismispurchasemaster.kpm_id=kismispurchase.kpm_id and where isnull(kismispurchase.availableqty,0)<>0");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900