Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7764381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:53:48+00:00 2026-06-01T14:53:48+00:00

I have been busy with a exercise where I need to compare a winning

  • 0

I have been busy with a exercise where I need to compare a winning lottery number(which is generated) with existing lottery numbers in a database table.

I manage to loop through all the numbers in the database and subsequently find matches with the winning set of numbers but am struggling to pinpoint in which set of lottery numbers the match was found.
The numbers were placed individually in each database column.
Here I retrieve the values in each row.

ResultSet set = state.executeQuery("SELECT * FROM numberLotto");
    while(set.next())
    {
                String[]row = new String[7]; 
                row[0] = set.getString(1);                   
                row[1] = set.getString(2);
                row[2] = set.getString(3);
                row[3] = set.getString(4);
                row[4] = set.getString(5);
                row[5] = set.getString(6);
                row[6] = set.getString(7);
                entries.add(row);
            }
String[][]listOfNumbers = entries.toArray(new String[entries.size()][7]);

I then loop through listOfNumbers and compare all the values with the values of winningNumber.

Object[]winningNumber = lottoDrawString.toArray();   

        for (int i=0; i < listOfNumbers.length; i++)
        {
            for (int j=0; j < listOfNumbers[i].length; j++)
            {
                for(int k = 0; k < winningNumber.length; k++)
                {
                    System.out.println(listOfNumbers[i][j]);

                    if(listOfNumbers[i][j].equals(winningNumber[k]))
                    {
                        System.out.println("There is a match " + listOfNumbers[i][j] + " and " + winningNumber[k]);
                    }
                }

            }
        }

How can I retrieve the row where the match(es) were found?

kind regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:53:49+00:00Added an answer on June 1, 2026 at 2:53 pm

    Why not just do

    SELECT * FROM numberLotto WHERE FirstNumber = n1 AND SecondNumber = n2 AND ...
    

    For that matter, why not just store the lotto numbers as a seven-digit string in the database?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been busy integrating Wordpress to one of a CakePHP application.Last Monday I
I have been busy in my project creating a webapp (in struts) that manages
I have a bachelor in computer science. And have been busy doing security research
$(#profile_bar).mouseover(function(){ <?php $_SESSION['sessionasdf'] = 'asdf'; ?> }); Hello! I have been busy with this
I have been busy building the UI for a class file I wrote a
I have been busy setting up authentication, a JDBC realm in particular, on GlassFish
I have been busy creating an app for Red5. Imagine what was my surprise
I have a fairly busy site which does around 10m views a month. One
I have been busy with the cakePHP framework for a couple of months now
Have been trying to encrypt an xml file to a string so that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.