hitecbill
12-06-2006, 06:44 AM
ok products db...for printers/copiers...
fields are print, copy, scan, fax...they will be either 1 or 0...
what would a query be to return any records that contain at least two of these columns?
i'm thinking this, but it doesn't seem too elegant?
select * from products where
(copy=1 and (print=1 or scan=1 or fax=1)) or
(print=1 and (copy=1 or scan=1 or fax=1)) or
(scan=1 and (copy=1 or print=1 or fax=1)) or
(fax=1 and (copy=1 or print=1 or scan=1))
fields are print, copy, scan, fax...they will be either 1 or 0...
what would a query be to return any records that contain at least two of these columns?
i'm thinking this, but it doesn't seem too elegant?
select * from products where
(copy=1 and (print=1 or scan=1 or fax=1)) or
(print=1 and (copy=1 or scan=1 or fax=1)) or
(scan=1 and (copy=1 or print=1 or fax=1)) or
(fax=1 and (copy=1 or print=1 or scan=1))