0

次の値を持つテーブルがあります

docid dcname doctitle 
1      **aa   **aaa01-01 
2      aa**   aafddg-02**
3      a**a   asds***90-05
4      abcd   abcd-06.

このテーブルで、** で始まり ** で終わる「Doctitles」の値をフィルタリングしたいと思います

私の結果は

dcid docname doctitle
3    a**a    asds***90-05
4    abcd    abcd-06

私は以下のクエリを使用していますが、得られた結果は真ん中に ** があるDoctitlesだけです

SELECT *
  FROM table1
 WHERE     doctitle NOT LIKE '**%'
       AND doctitle NOT LIKE '%**'
       AND doctitle LIKE '%**%'

これにより、以下の結果のみが得られます dcid docname doctitle 3 a* a asds **90-05

これについて助けが必要です。

4

6 に答える 6

0

and doctitle like '%**%' あなたのクエリが見えるはずですselect * from table1 where doctitle not like '**%' and doctitle not like '%**'

別の解決策:

SELECT * FROM table1 WHERE LEFT(doctitle,2) != '**' AND RIGHT(doctitle,2) != '**'
于 2013-10-28T06:10:39.660 に答える
0

次のオプションを試してください

select * from table1 where doctitle like '**%' and doctitle like '%**'

また

select * from table1 where doctitle like '**%'
UNION
select * from table1 where doctitle like '%**'

詳細については、これを参照してください

于 2013-10-28T06:12:13.823 に答える
0

私はそれを試してみましたが、うまくいきました -

select * from 
(
select 
1    docid ,  '**aa' dcname  ,  '**aaa01-01' doctitle 
from dual
union all  
select 
2,      'aa**',   'aafddg-02**'
from dual
union all
select 
3 ,     'a**a' ,  'asds***90-05'
from dual
union all
select 
4  ,    'abcd'  , 'abcd-06.'
from dual
)
where doctitle not like '**%' and doctitle not like '%**'  
于 2013-10-28T06:14:34.897 に答える
0

で始まるまたは終わる s を望まないことを意味していると仮定すると、最後の条件を省略するだけで済みます。doctitle**

SELECT *
FROM   table1
WHERE  doctitle NOT LIKE '**%'
  AND  doctitle NOT LIKE '%**'
于 2013-10-28T06:15:44.463 に答える
0

これを試して..

SELECT  *
FROM    table1
WHERE   doctitle LIKE '%**%'
AND     docid  NOT IN (SELECT docid  FROM tabel1 WHERE doctitle NOT LIKE '**%' )
AND     docid  NOT IN (SELECT docid  FROM tabel1 WHERE doctitle NOT LIKE '%**' )
于 2013-10-28T06:21:26.963 に答える
0

SELECT * FROM table1 WHERE doctitle NOT LIKE ' %' OR doctitle NOT LIKE '% '

于 2013-10-28T06:22:09.353 に答える