Your question is a bit confusing. Here are the possibilities using AND:

SELECT id FROM table WHERE col1 = a AND col2 = b;

SELECT id FROM table WHERE col1 = a AND col2 <> b;

SELECT id FROM table WHERE col1 <> a AND col2 = b;

SELECT id FROM table WHERE col1 <> a AND col2 <> b;

[ BTW, you can also write the last one as:
SELECT id FROM table WHERE NOT (col1 = a OR col2 = b); ]

Basically, what you want to do is to use <> in place of = if you want to test for the negative of a condition.


Date: Sat, 06 Nov 2004 20:34:47 -0800
To: [EMAIL PROTECTED]
From: "L a n a" <[EMAIL PROTECTED]>
Subject: mysql  NOT operator
Message-ID: <[EMAIL PROTECTED]>

Hello,

Could you please tell me how I can write an sql statement in php when I'd llike to select boolean search in one field like "except" or "NOT" result.
What I mean here is that I can execute the following:
1. SELECT data_id from table WHERE keyword = a AND keyword =b
2. SELECT data_id from table WHERE keyword = a OR keyword =b


However, NOT operator gives an error:
3. SELECT data_id from table WHERE keyword = a NOT keyword =b ( returns sql error)


Could you please help?
Thank you,
Lana



-- Jon Stephens, Technical Writer MySQL AB www.mysql.com Office: +61 (07) 3388 2228 Are you MySQL certified? www.mysql.com/certification

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to