2017-06-13 46 views
1

Documentation說:如何在獅身人面像中使用NOT?

WHERE子句。該子句將映射到全文查詢和過濾器。 比較運算符(=,!=,<,>,< =,> =),IN,AND,NOT和BETWEEN 都支持並直接映射到過濾器

但是,當我試圖選擇數據使用下一個查詢我有麻煩:

mysql> select * from content where NOT sentiment = 1; 
ERROR 1064 (42000): sphinxql: syntax error, unexpected NOT, expecting IDENT (or 56 other tokens) near 'NOT sentiment = 1' 

什麼是錯?

回答

1

NOT是一種運算符,通常與其他運算符結合使用,如IN或處理布爾值或NULL;

有效例子:

SELECT * FROM content WHERE sentiment IS NOT TRUE; 
SELECT * FROM content WHERE sentiment IS NOT NULL; 
SELECT * FROM content WHERE sentiment NOT IN (1, 2); 
SELECT * FROM content WHERE sentiment NOT BETWEEN 1 AND 5; 

你也可以把它當作一個邏輯NOT它會反轉零和非零值:

SELECT NOT (1+3); /* 0 */ 
SELECT NOT 0;  /* 1 */ 

您查詢應使用!=<>運營商:

SELECT * FROM content WHERE sentiment != 1; 
SELECT * FROM content WHERE sentiment <> 1;