SQL选择Concat不同的所有位置

时间:2015-09-16 16:29:23

标签: mysql select distinct concat

我正在寻找创建一个select语句,当两个行的串联不同时,我选择所有列和行。我在下面有我的SQL语句。但是,我不确定如何正确创建此声明,如何编写此声明?

$query = "SELECT * FROM APPROVED 
  WHERE DISTINCT CONCAT(P_NUMBER,'-',A_NUMBER) AS CNUMBER 
  AND (STATUS = 'ACTIVE' OR STATUS = 'CLOSED' OR STATUS = 'CLOSING' OR STATUS = 'PENDING')"; 

1 个答案:

答案 0 :(得分:0)

DISTINCT用于列选择。有几种方法可以做到这一点:

$scope.company.push("Other")// May it be a object

应该与

几乎完全相同
import java.util.Scanner;
import java.util.Random;
public class RPSGameFinal {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    System.out.println("Welcome to Rock Paper Scissors!  Best two out of three!");
    System.out.println("Please enter \"Rock\", \"Paper\", or \"Scissors\".");
    int playerWins = 0;
    int computerWins = 0;
    int roundNumber = 0;

    if (roundNumber < 3)
    {
        while (roundNumber != 2)
        {
            Scanner keyboard = new Scanner(System.in);
            String playerChoice = keyboard.next();
            if (playerChoice.equalsIgnoreCase("Rock"))
            {
                roundNumber = roundNumber + 1;
                Random computerChoice = new Random();
                int choiceValue = computerChoice.nextInt(3) + 1;
                if (choiceValue == 1)
                {
                    System.out.println("Rock vs Rock, Tie!");
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    System.out.println("Enter \"Rock\", \"Paper\", or \"Scissors\".");
                }
                else if (choiceValue == 2)
                {
                    System.out.println("Rock vs Paper, Computer Wins!");
                    computerWins = computerWins + 1;
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    System.out.println("Enter \"Rock\", \"Paper\", or \"Scissors\".");
                }
                else if (choiceValue == 3)
                {
                    System.out.println("Rock vs Scissors, Player wins!");
                    playerWins = playerWins + 1;
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    System.out.println("Enter \"Rock\", \"Paper\", or \"Scissors\".");
                }
            }
            else if (playerChoice.equalsIgnoreCase("Paper"))
            {
                roundNumber = roundNumber + 1;
                Random computerChoice = new Random();
                int choiceValue = computerChoice.nextInt(3) + 1;
                if (choiceValue == 1)
                {
                    System.out.println("Paper vs Rock, Player wins!");
                    playerWins = playerWins + 1;
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    System.out.println("Enter \"Rock\", \"Paper\", or \"Scissors\".");
                }
                else if (choiceValue == 2)
                {
                    System.out.println("Paper vs Paper, Tie!");
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    System.out.println("Enter \"Rock\", \"Paper\", or \"Scissors\".");
                }
                else if (choiceValue == 3)
                {
                    System.out.println("Paper vs Scissors, Computer wins!");
                    computerWins = computerWins + 1;
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    System.out.println("Enter \"Rock\", \"Paper\", or \"Scissors\".");
                }
            }
            else if (playerChoice.equalsIgnoreCase("Scissors"))
            {
                roundNumber = roundNumber + 1;
                Random computerChoice = new Random();
                int choiceValue = computerChoice.nextInt(3) + 1;
                if (choiceValue == 1)
                {
                    System.out.println("Scissors vs Rock, Computer wins!");
                    computerWins = computerWins + 1;
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    System.out.println("Enter \"Rock\", \"Paper\", or \"Scissors\".");
                }
                else if (choiceValue == 2)
                {
                    System.out.println("Scissors vs Paper, Player wins!");
                    playerWins = playerWins + 1;
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    System.out.println("Enter \"Rock\", \"Paper\", or \"Scissors\".");
                }
                else if (choiceValue == 3)
                {
                    System.out.println("Scissors vs Scissors, Tie!");
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    System.out.println("Enter \"Rock\", \"Paper\", or \"Scissors\".");
                }
            }
        }
        if (roundNumber == 2);
        {
            Scanner keyboard2 = new Scanner(System.in);
            String input2 = keyboard2.next();
            if (input2.equalsIgnoreCase("Rock"))
            {
                Random computerChoice2 = new Random();
                int choiceValue2 = computerChoice2.nextInt(3) + 1;
                if (choiceValue2 == 1)
                {
                    System.out.println("Rock vs Rock, Tie!");
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    if (playerWins > computerWins)
                    {
                        System.out.println("Player wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins < computerWins)
                    {
                        System.out.println("Computer wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins == computerWins)
                    {
                        System.out.println("Tie game!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                }
                else if (choiceValue2 == 2)
                {
                    System.out.println("Rock vs Paper, Computer wins!");
                    computerWins = computerWins + 1;
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    if (playerWins > computerWins)
                    {
                        System.out.println("Player wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins < computerWins)
                    {
                        System.out.println("Computer wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins == computerWins)
                    {
                        System.out.println("Tie game!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                }
                else if (choiceValue2 == 3)
                {
                    System.out.println("Rock vs Scissors, Player wins!");
                    playerWins = playerWins + 1;
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    if (playerWins > computerWins)
                    {
                        System.out.println("Player wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins < computerWins)
                    {
                        System.out.println("Computer wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins == computerWins)
                    {
                        System.out.println("Tie game!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                }
            }
            else if (input2.equalsIgnoreCase("Paper"))
            {
                Random computerChoice2 = new Random();
                int choiceValue2 = computerChoice2.nextInt(3) + 1;
                if (choiceValue2 == 1)
                {
                    System.out.println("Paper vs Rock, Player wins!");
                    playerWins = playerWins + 1;
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    if (playerWins > computerWins)
                    {
                        System.out.println("Player wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins < computerWins)
                    {
                        System.out.println("Computer wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins == computerWins)
                    {
                        System.out.println("Tie game!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                }
                else if (choiceValue2 == 2)
                {
                    System.out.println("Paper vs Paper, Tie!");
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    if (playerWins > computerWins)
                    {
                        System.out.println("Player wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins < computerWins)
                    {
                        System.out.println("Computer wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins == computerWins)
                    {
                        System.out.println("Tie game!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                }
                else if (choiceValue2 == 3)
                {
                    System.out.println("Paper vs Scissors, Computer wins!");
                    computerWins = computerWins + 1;
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    if (playerWins > computerWins)
                    {
                        System.out.println("Player wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins < computerWins)
                    {
                        System.out.println("Computer wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins == computerWins)
                    {
                        System.out.println("Tie game!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                }
            }
            else if (input2.equalsIgnoreCase("Scissors"))
            {
                Random computerChoice2 = new Random();
                int choiceValue2 = computerChoice2.nextInt(3) + 1;
                if (choiceValue2 == 1)
                {
                    System.out.println("Scissors vs Rock, Computer wins!");
                    computerWins = computerWins + 1;
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    if (playerWins > computerWins)
                    {
                        System.out.println("Player wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins < computerWins)
                    {
                        System.out.println("Computer wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins == computerWins)
                    {
                        System.out.println("Tie game!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                }
                else if (choiceValue2 == 2)
                {
                    System.out.println("Scissors vs Paper, Player wins!");
                    playerWins = playerWins + 1;
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    if (playerWins > computerWins)
                    {
                        System.out.println("Player wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins < computerWins)
                    {
                        System.out.println("Computer wins!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins == computerWins)
                    {
                        System.out.println("Tie game!");
                        System.out.println("Play again?");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                }
                else if (choiceValue2 == 3)
                {
                    System.out.println("Scissors vs Scissors, Tie!");
                    System.out.println("Player has won "+playerWins+" times and the computer has won "+computerWins+" times.");
                    if (playerWins > computerWins)
                    {
                        System.out.println("Player wins!");
                        System.out.println("Play again?  Enter Yes or No.");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins < computerWins)
                    {
                        System.out.println("Computer wins!");
                        System.out.println("Play again?  Enter Yes or No.");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                    else if (playerWins == computerWins)
                    {
                        System.out.println("Tie game!");
                        System.out.println("Play again?  Enter Yes or No.");
                        Scanner keyboard3 = new Scanner(System.in);
                        String input3 = keyboard3.next();
                        if (input3.equalsIgnoreCase("Yes"))
                        {

                        }
                        else
                        {
                            System.out.println("Thank you for playing!");
                        }
                    }
                }
            }
        }   
    }
}
}

第二个不包括结果中的连接,第一个仅包括连接。您需要指定要返回的所有列。