Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Suppose I have two arrays. One looking like (3, 9, 10, 39), and one looking like (4, 10, 9, 48, 391, 2).

How would I (through pure MySQL) check if one of the elements in the first array is inside the other array?

Edit By checking, I mean returning true if one item of the first array is occuring in the second array.

Example:

SELECT IsElementFromFirstArrayInAnotherArray(array1, array2) AS isInArray
share|improve this question
2  
There is no "array" datatype in MySQL. How are the numbers stored in the database? In the same column, one number per row/field? All in the same field, comma-separated? –  ypercube Mar 19 '13 at 15:34
    
array1 is a field with comma-separated values. array2 is a direct array that I parse into the query string with the syntax (1,2,3,4,2) etc. –  Mathias Lykkegaard Lorenzen Mar 20 '13 at 8:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.