0
I need to create a code where I update a field always adding a value to what already exists.
Example table assuming this population is already
CAMPOS: ID | EMAIL | QUEMCURTIU
1 |[email protected]| 3, 46, 81,
// below the owner user ID ($id = 36) clicked to like
UPDATE table SET WHO likes = WHO likes + "$id";
CAMPOS: ID | EMAIL | QUEMCURTIU
1 |[email protected]| 3, 46, 81, 36
So far so good , however what would need now was to make a select based on these separate values some idea? What I’m trying is something like
SELECT * FROM TABLE WHERE WHO LIKES NOT LIKE %$id%
but this way if it has the number 14 and 144 of the wrong any idea of UPDATE and SELECT differently is welcome
They say the fewer appointments, the better? (performance) following this idea I want to finalize my idea using a single table, my system using 3 tables doing the same function this working, I’m just looking for other means ( I will test the performance of the 2 types sql benchmark)
– Arsom Nolasco
in the case there the ID 36 is that of the user who clicked on to like , the ID 1 is of @dvd another user | if the ID 1 click on Like the ID 36 will be inserted in the field WHO likes it the following -> 1, | if the ID 24 click on Like the ID 36 will be inserted in the field WHO likes it the following -> 1, 24
– Arsom Nolasco
but I’m scrambling with select which searches for text within the field
– Arsom Nolasco
yes this code I wrote there running actually this adding, I am using Concat to enter the ids, as the comma and I was searching to perform the query via a joker
– Arsom Nolasco
yes however that is not the problem . my problem is the issue of SELECT
– Arsom Nolasco
You’d have to create the pattern:
,3,46,81,36,
.. makes it easier to find the value withLIKE '%,$id,%'
– Sam
The "QUEMCURTIU" field would have to have as default value the comma, and you just add the values with the update:
UPDATE tabela SET QUEMCURTIU = QUEMCURTIU + '$id,';
... the result will be numbers delimited by comma before and after, avoiding the confusion of 14 and 144.– Sam
which bank is ? you could use an array field as well... or do what the dvd said
– Rovann Linhalis
@Rovannlinhalis mysql , I’m trying to get no more will $sql = "SELECT * FROM usuarios WHERE email <> '$email' AND canaisquejaseinscreveu NOT LIKE ',%%,' ";
– Arsom Nolasco