#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Need help about query


    Hi,

    I need help abt query.
    to simplify say I have a table like this

    Game_Table

    Match_ID Team1 Team2 Match_date
    1 101 102 11.11.2011
    2 104 110 12.11.2011



    SO i want to make a query which tells me team 101 and team 102 is in the same row.

    I mean i need a query which will tell me this

    IF (team1 and team2 has same Match_ID) {
    return true;
    }
    else {
    return false;
    }
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,244
    Rep Power
    4279
    could you please rephrase your question?

    as it stands, ~every~ row returned from this table has two teams which have the same match_id
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by r937
    could you please rephrase your question?

    as it stands, ~every~ row returned from this table has two teams which have the same match_id
    i am trying to make a simple game.

    so think i have player table and ofcourse every player has a team.

    So if the player A's team (team ID: 101) has a match against player B's team (team ID 102). i do not want player A can talk to player B if they have a match against each other.

    So I want to create a function. we can call it

    function chat()
    {
    If (here is the query will check if the player A and PlayerB's teams are going to have a match against each other)
    {
    return false;
    }
    else
    {return true;}
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,244
    Rep Power
    4279
    Code:
    SELECT 'yes'
      FROM game_table
     WHERE team1 = 101 AND team2 = 102
        OR team1 = 102 AND team2 = 101
    this query either returns one or more rows with 'yes' or else it returns no rows at all

    Comments on this post

    • romansmac agrees : thanks a lot mate. thats what i want
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo