Sub query in a single SQL field

0

I need to create a code where I do the UPDATE of a field always adding a value to what already exists.

Example table assuming it is already population

CAMPOS: ID | EMAIL | QUEMCURTIU
        1  |[email protected]| 3, 46, 81, 

// below the user ID owner ($ id = 36) clicked on to enjoy

UPDATE table SET QUEMCURTIU = QUEMCURTIU + "$ id";

 CAMPOS: ID | EMAIL | QUEMCURTIU
         1  |[email protected]| 3, 46, 81, 36  

So far so good, but what I need now was to make a select based on these separated values some idea? What I'm trying is something like

SELECT * FROM TABLE WHERE QUEMCURTIU NOT LIKE% $ id%

However, if you have the number 14 and 144 wrong any idea of UPDATE and SELECT differently is welcome

    
asked by anonymous 01.04.2018 / 06:05

1 answer

0

SELECT * FROM TABELA WHERE FIND_IN_SET($id, QUEMCURTIU) = 0

Although it works, my comment on the question is still valid. If your argument is performance, this is much worse than normalizing the relationship correctly, as well as not being a standard SQL function.

    
01.04.2018 / 17:32