Hoi,
Ik heb deze tabel:
tabel-naam: x
----------------
id (int 11) | users (varchar 255)
-----------------------------------
1 | ruud,piet,sjaak,hendrik
2 | piet,sjaak
3 | ruud
4 | sjaak,hendrik,ruud
Nu wil ik een query maken die kijkt of de naam 'ruud' in de kolom 'users' staat.
Ik wist dat er een query was die dit kon iets like:
SELECT * FROM x WHERE ruud IS IN LIST users
of iets dergelijks..
Iemand enig idee?? Ik zoek me al een uur een ongeluk.. word er gek van ..
Heb al gezocht enz enz.. niemand schijnt het te weten...
Ik heb deze tabel:
tabel-naam: x
----------------
id (int 11) | users (varchar 255)
-----------------------------------
1 | ruud,piet,sjaak,hendrik
2 | piet,sjaak
3 | ruud
4 | sjaak,hendrik,ruud
Nu wil ik een query maken die kijkt of de naam 'ruud' in de kolom 'users' staat.
Ik wist dat er een query was die dit kon iets like:
SELECT * FROM x WHERE ruud IS IN LIST users
of iets dergelijks..
Iemand enig idee?? Ik zoek me al een uur een ongeluk.. word er gek van ..
(dit las ik op mysql.com maar hoe verwerk ik dit nu tot wat ik wil?)expr IN (value,...)
Returns 1 if expr is any of the values in the IN list, else returns 0. If all values are constants, they are evaluated according to the type of expr and sorted. The search for the item then is done using a binary search. This means IN is very quick if the IN value list consists entirely of constants. If expr is a case-sensitive string expression, the string comparison is performed in case-sensitive fashion.
mysql> SELECT 2 IN (0,3,5,'wefwf');
-> 0
mysql> SELECT 'wefwf' IN (0,3,5,'wefwf');
-> 1
The number of values in the IN list is only limited by the max_allowed_packet value. To comply with the SQL standard, from MySQL 4.1 on IN returns NULL not only if the expression on the left hand side is NULL, but also if no match is found in the list and one of the expressions in the list is NULL. From MySQL 4.1 on, IN() syntax also is used to write certain types of subqueries. See section 14.1.8.3 Subqueries with ANY, IN, and SOME.
Heb al gezocht enz enz.. niemand schijnt het te weten...