how to select the records whose several fields' combination will equal to a specific value

Posted by poiu2000 on Stack Overflow See other posts from Stack Overflow or by poiu2000
Published on 2010-03-15T09:20:29Z Indexed on 2010/03/15 9:29 UTC
Read the original article Hit count: 153

Filed under:

Hi all,

Assume I have the following style table, col1 col2 and col3 have same value scopes, I want to select the records when two of the 3 columns have a value combination such as ('ab' and 'bc'), in the following example, the first 3 records should be selected. Any good way to do this? I am using Sybase.

| id | col1 | col2 | col3 |
  1     ab     bc     null
  2     null   ab     bc
  3     ab     ab     bc
  4     de     ab     xy

Thanks.

© Stack Overflow or respective owner

Related posts about sql