0

I have a MySQL table with 1 column containing a set of numbers eg. 10, 18, 22, 56, 89 etc. I have about 6000 rows of different user inputs with the same column of different values.

I want to select the columns that have the exact match of numbers I am searching for. eg. SELECT * from my_table WHERE column CONTAINS num1, num2, num3. I cant seem to get it to work. It still selects all the records containing even one of the value and not the exact match.

My database is a lottery table and I want to be able to find the winners in 2 to 6 number matches - after the result draw.

Thanks in advance for your help!

EDIT I want to return only columns containing a fixed set of numbers (string). Not all columns containing any of the numbers.

Joe
  • 3
  • 3
  • `SELECT * from my_table WHERE column IN(num1, num2, num3)` should do it,, – Romeo Sierra Jun 08 '18 at 06:14
  • Hi Romeo, thanks for your suggestion. However, this returns columns containing one of the numbers and not the exact set of numbers. eg. SELECT all_number_line from game_plays WHERE `all_number_line` IN(8, 12, 32) Returns all rows containing 8, 12 and 32 and not exact rows containing all three numbers or two of those. – Joe Jun 08 '18 at 06:19
  • @Meloman thanks but no it isn't. I have seen that question. It does not relate to mine. IN clause alone does not resolve my issue. Thanks. – Joe Jun 08 '18 at 06:22
  • What do you mean by *set of numbers*? Is it a string of CSV? – Romeo Sierra Jun 08 '18 at 06:24
  • @Romeo a "string" – Joe Jun 08 '18 at 06:25
  • A string with comma separated values (CSV)? – Romeo Sierra Jun 08 '18 at 06:26
  • Ok, I understand... in one column, you could have 10, 18, 22, 56, 89 and if you search for 10 and 22 column must be in result? – Meloman Jun 08 '18 at 07:06
  • @Meloman. Yes that is right. – Joe Jun 08 '18 at 08:19
  • So I have changed the structure of my table and rephrased the question here. https://stackoverflow.com/questions/50756396/mysql-select-rows-with-values-from-a-variable-string – Joe Jun 08 '18 at 08:23
  • So you would need to use `WHERE column LIKE '%10%' AND column LIKE '%22%' AND ...` – Meloman Jun 08 '18 at 08:27

0 Answers0