SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Dec 2000
    Location
    Karachi, Pakistan
    Posts
    913
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is this a Correct SQL Statement

    Hello Guys,

    Is this a correct SQL Statement?

    $m2Sql = "select * from matches where player1=$MemberId OR player2 = $MemberId AND status = 2";

    If not, can you please correct me?

    I want to select all the matches in which 5 is listed in either player1 field or player2 field. Also all the matches selected must have its status field value to be 2.

    Thanks in advance,

    Regards,
    Omair
    36Host.com - $36/year web hosting [affiliates earn 30%]
    * Affordable Small Business Web Hosting since 2003! *
    "500mb space, 10gb bandwith, 50 pop/ftp accounts, php,
    mysql, pre-installed php scripts, 24/7 support & more...."



  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2001
    Location
    location location
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Omair Haroon
    Hello Guys,

    Is this a correct SQL Statement?

    $m2Sql = "select * from matches where player1=$MemberId OR player2 = $MemberId AND status = 2";

    If not, can you please correct me?

    I want to select all the matches in which 5 is listed in either player1 field or player2 field. Also all the matches selected must have its status field value to be 2.

    Thanks in advance,

    Regards,
    Omair

    I'd say you're missing brackets, so this

    $m2Sql = "select * from matches where (player1=$MemberId OR player2 = $MemberId) AND status = 2";


  3. #3
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To make it more 'cuter'

    Code:
    $m2Sql = "SELECT * FROM matches WHERE (player1 = $memberId OR player2 = $MemberId) AND status = 2";
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •