www.webdeveloper.com
Results 1 to 3 of 3

Thread: Query not formatted correctly?

  1. #1
    Join Date
    Mar 2014
    Location
    Corpus Christi, TX
    Posts
    83

    Query not formatted correctly?

    Howdy Team,

    I hope all who celebrated had a good Easter.

    I am trying to update some records in MySQL, but am not getting the result I want.

    PHP Code:
    $query=("UPDATE bridges SET issuecreated = 'New' WHERE onlysignal<=-83 OR CCQ<=89 AND issuecreated == 'No'"); 
    It seems to be finding the correct records that meet the WHERE and OR clause, but I only want to update records where "issuecreated" is equal to No. It is updating all records it finds where the first two parameters are met.

    I imagine the problem lies in my last criteria, but cannot seem to fix this.

    Thoughts?

  2. #2
    Join Date
    Dec 2011
    Location
    Centurion, South Africa
    Posts
    795
    You don't need double equals to compare, just one will do. Also, I grouped your OR conditions so the AND will be used in both cases:

    PHP Code:
    $query = ("UPDATE bridges SET issuecreated = 'New' WHERE (onlysignal<=-83 OR CCQ<=89) AND issuecreated = 'No'"); 
    JavaScript: Learn | Validate | Compact | bionoid

  3. #3
    Join Date
    Mar 2014
    Location
    Corpus Christi, TX
    Posts
    83
    That did it. Thank you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles