Results 1 to 4 of 4

Thread: query not executing

  1. #1
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default query not executing

    I created a customized query to search through my database for a given range of numbers, however when I do it the general way it cannot execute

    PHP Code:
    $query mysqli_query($conn"SELECT doc_id,ref_number,title,description FROM docs WHERE ref_number=DD%"); 
    -or-
    PHP Code:
    $query mysqli_query($conn"SELECT doc_id,ref_number,title,description FROM docs WHERE ref_number LIKE DD%"); 
    however if I change the query to search for 1 document by the ID, it will execute correctly.
    PHP Code:
    $query mysqli_query($conn"SELECT doc_id,ref_number,title,description FROM docs WHERE doc_id=680"); 

    is this a possible INDEXing problem?

    Note: doc_id is the primary key of the table, and ref_number indexed :| or so I thought
    Last edited by boogyman; 05-29-2007 at 04:11 PM.

  2. #2
    Join Date
    May 2007
    Location
    Sweden
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    Hi Boogyman!

    When you seach without "LIKE" you cannot use %-sign, and you forgoted to add ' between LIKE DD% Set it to LIKE 'DD%'. See if this get the results as you want it!

    PHP Code:
    $query mysqli_query($conn"SELECT doc_id,ref_number,title,description FROM docs WHERE ref_number LIKE 'DD%'"); 
    PHP Code:
    $query mysqli_query($conn"SELECT doc_id,ref_number,title,description FROM docs WHERE ref_number=DD"); 
    Best regards,
    mbrodin

  3. #3
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by mbrodin View Post
    you forgoted to add ' between LIKE DD% Set it to LIKE 'DD%'. See if this get the results as you want it!
    ahh, the joys of minute character flaws Thanks Mate, that did do the trick

  4. #4
    Join Date
    May 2007
    Location
    Sweden
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    Quote Originally Posted by boogyman View Post
    ahh, the joys of minute character flaws Thanks Mate, that did do the trick
    Great! Always nice to help!

    Best regards,
    mbrodin

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
  •