0

我想检查列数中存在的给定名称。我在下面发布了我的表记录结构。我想过滤给定名称的批准列表详细信息。

  Name      forward1   forward2    forward3   forward4  forward5  status
  Ajay      vino       arun         jose                          Approved
  Hersone   arun       jose                                       Pending
  Stefi     vino       jose         arun                          Approved
  Alex      arun       Hersone      vino                          Approved

我需要具有如下批准状态的 Jose 记录:

  Name      forward1   forward2    forward3   forward4  forward5  status
  Ajay      vino       arun         jose                          Approved
  Stefi     vino       jose         arun                          Approved

我是这个领域的新手。请帮我做这件事。对不起我的英语不好

4

3 回答 3

0
query = select * from table_name where forward3 = 'jose' and status = 'approved'
于 2012-07-25T07:27:31.583 回答
0

这应该有效:

SELECT *
FROM my_table
WHERE status= 'Approved' AND
      (forward1 LIKE '%jose%' OR  
       forward2 LIKE '%jose%' OR  
       forward3 LIKE '%jose%' OR  
       forward4 LIKE '%jose%' OR  
       forward5 LIKE '%jose%');

编辑:WHERE condition取决于您可以使用的完全匹配的要求forward1 = 'jose'

于 2012-07-25T07:23:17.400 回答
0

请尝试以下:

SELECT *
FROM tableA
WHERE status= 'Approved' AND
      (forward1 ='jose' OR  forward2 ='jose' OR  forward3 ='jose' 
        OR  forward4 ='jose'  OR  forward5 ='jose');
于 2012-07-25T07:26:04.550 回答