0

I do have a problem with a query. I spend hours trying to find a way to make it work but I can't :( Even if it feels easy !

Let's say I have this table:

entity_id    delta    name
----------------------------
1            0        speaker
1            1        screen
2            0        mouse
2            1        TV
2            2        tablet

I simply want to return the entity id of a content where name != 'speaker' (in this example, it would be entity_id = 2).

If I use "name LIKE 'speaker'", it returns me entity 1. But I want the other way. So I try to use "name NOT LIKE 'test'", it returns me all the other rows, which is normal, but I would like to only get entity_id 2.

I feel like I am missing something easy.

Thanks for you help !

Ed

4
  • I'm find difficult to understand, can you please formulate an example? Commented Dec 14, 2015 at 0:18
  • I tried to correct a few sentences and use different names. Is it better? Commented Dec 14, 2015 at 0:25
  • 2
    but in your second row, "screen" has entity_id "1". So, that's NOT "speaker", but still "1" (???) Commented Dec 14, 2015 at 0:25
  • See answer from @juergen d, it is a multi field value so multiple rows can be linked to the same content. Sorry I wasn't clear enough. Thanks! Commented Dec 14, 2015 at 0:30

1 Answer 1

1
select entity_id
from your_table
group by entity_id
having sum(name = 'test') = 0
Sign up to request clarification or add additional context in comments.

1 Comment

Works great ! Thanks a lot :)

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.