0

Using MariadB, how can I combine NOT LIKE and LIKE, so that I can search for the string FHD but exclude from the searches if the string H265 is also present?

This didn't work for me:

SELECT  `id` FROM `qualities`.`streams` WHERE quality LIKE '%FHD%' AND NOT LIKE '%H265%';
1

You probably got an error like Incorrect syntax near the keyword LIKE, because each of the ("NOT LIKE" and "LIKE") conditions needs to specify the column is is working on. If so, this should work:

SELECT  `id` FROM `qualities`.`streams` WHERE quality LIKE '%FHD%' AND quality NOT LIKE '%H265%';
  • Perfect! Thanks, now I understand – Freedo Oct 15 at 6:37
  • Is it possible to group more than 1 thing in like and not like? I'm finding myself writing very long queries because of this – Freedo Oct 15 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.