我正在寻找一种检查 MySQL 表中所有字段的方法。假设我有一个 MySQL 表,其中包含字段One
Two
Three
Four
Five
和Big One
. 这些字段包含人们输入的数字,有点像百万富翁。用户输入数字,它会插入他们从最小到最大选择的数字。
号码将被抽出,我需要一种方法来检查每个用户选择的任何号码是否与抽出的中奖号码相匹配,对于Big One
. 如果有任何匹配,我会让它做一些特定的事情,比如一个数字或所有数字是否匹配。
我希望你明白我在说什么。谢谢你。
I would imagine MySQL has some sort of 'set' logic in it, but if it's lacking, I know Python has sets, so I'll use an example of those in my solution:
Create a set with the numbers of the winning ticket:
winners = set({11, 22, 33, 44, 55})
For each query, jam all it's numbers into a set too:
current_user = set({$query[0], $query[1], $query[2]...$query[4]})
Print out how many overlapping numbers there are:
print winners.intersection(current_user)
And finally, for the 'big one', use an if statement.
Let me know if this helps.