简体   繁体   中英

Zend_Db WHERE NOT

I'm in need of building a query like this in with Zend_Db:

SELECT * FROM mytable
WHERE NOT (field1 = 0.00 AND field2 = 0.00  AND field3 = 0.00);

How can I accomplish this with Zend_Db, also is the MySQL approach correct? (if all three fields are 0.00 then ignore it).

Thanks for the replies!

I think this should do it:

$db->select()
    ->from('mytable')
    ->where('field1 != 0.00')
    ->where('field2 != 0.00')
    ->where('field3 != 0.00');

I think it should be

$query = $this->select()
              ->from('mytable')
              ->where('field1 <> ? AND field2 <> ? AND field3 <> ?', 0, 2) /*2 is Zend_Db::FLOAT_TYPE*/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM