怎么写WHERE没有

I am trying to write a query which will select the column "batchinstructor" from the table "batch" where batchname="$batchname" and the value of "batchid" shouldn't be "$batchid".

I have managed to write the following but it is clearly wrong, would you please kindly correct it for me?

SELECT batchinstructor 
FROM batch 
WHERE batchname='$batchname AND batchid is not= '$batchid'
SELECT batchinstructor 
FROM batch 
WHERE batchname='$batchname' and  batchid <> '$batchid'
SELECT batchinstructor 
FROM batch 
WHERE batchname='$batchname' and batchid <> '$batchid'

or

SELECT batchinstructor 
FROM batch 
WHERE batchname='$batchname' and batchid != '$batchid'

Note that if batchid is NULL in the table, this won't work. For that, you indeed need to check using IS NOT NULL, because the check 'NULL <> 1' will actually return false, thus returning the records where batchid is NULL. If you got NULL records, you need to change the query to:

SELECT batchinstructor 
FROM batch 
WHERE 
  batchname='$batchname' and 
  (batchid is null or batchid != '$batchid')
SELECT batchinstructor
  FROM batch
 WHERE batchname='$batchname and  batchid <> '$batchid'

This is standard SQL. Some SQL dialects would use

SELECT batchinstructor
  FROM batch
 WHERE batchname='$batchname and  batchid != '$batchid'