Hi to all keen folks,

can you help me to query the first 4 letters and the last 4 letters in one field.

example: AAAABBBBCCCCDDDD how to query AAAA and DDDD.

thank you.

Recommended Answers

All 3 Replies

Quickest option, although it isn't restricted to only four characters would be to:

select * from `example` where `content` like 'AAAA%' or `content` like '%DDDD';

For a more precise solution, I would look to use MySQL regular expressions.

Hope this helps,
R.

in regexp like this

select myletters from testing_letters where myletters regexp '^AAAA' and myletter regexp 'DDDD$'

thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.