0

In my column I can have either a string like : "data+" or "data+data+data+..(undefined times)..+" I simply need to get the column where I have multiples data and not only one.

I tried with

mycol NOT LIKE '%+'

But it didn't work...

Actually I don't know the data it is a string that varies : 'blabla' or 'aString' or 'whatever'

If I had in my columns

'jdsjpgsg+jdsjpgsg+', 'dvgff+', 'ffef+eefds+ghghgh+'

I want to select only

'jdsjpgsg+jdsjpgsg+',
'ffef+eefds+ghghgh+', 

NOT 'dvgff+' !

1
  • Try mycol NOT LIKE 'data+%' Commented Jun 8, 2018 at 8:27

2 Answers 2

1

if you want to search '..xxx+..' then you should be use xxx+%

if you want to search '..+xxx..' then you should be use %+xxx

if you want to search '..++..' then you should be use %++%

if you want to search '..+..+..' then you should be use %+%+%


It is what I get too and I dont want that. It is actually what i don't want to select. If I had jdsjpgsg+jdsjpgsg+ in my table I want to select it and NOT jdsjpgsg+ It is tricky...

so you can try like '%+%+%' to exclude just one '+'

CREATE TABLE TestTable
    (`text` varchar(90))
;

INSERT INTO TestTable
    (`text`)
VALUES
    ('jdsjpgsg+jdsjpgsg+'),
    ('dvgff+'),
    ('ffef+eefds+ghghgh+')
;

select * from TestTable
where text like '%+%+%'

|               text |
|--------------------|
| jdsjpgsg+jdsjpgsg+ |
| ffef+eefds+ghghgh+ |

SQL Fiddle Demo Link

Sign up to request clarification or add additional context in comments.

1 Comment

It is what I get too and I dont want that. It is actually what i don't want to select. If I had jdsjpgsg+jdsjpgsg+ in my table I want to select it and NOT jdsjpgsg+ It is tricky....
0

The % is the wildcard character. You should be using the % after data. Try like:

SELECT * FROM `table` WHERE `mycol` NOT LIKE 'data+%'

The above query will filter out all the records that have any characters after data+.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.