www.webdeveloper.com
Results 1 to 2 of 2

Thread: SQL Query returning to many results

  1. #1
    Join Date
    Apr 2012
    Posts
    12

    SQL Query returning to many results

    Hello, I have a query where I am attempting to find records where a certain string appears in a given text field. For some reason, the below query returns multiple results when only a single record should be returned, and as part of the result set, it lists the same comment for every program. for some reason my
    Code:
    WHERE programComments.comment LIKE '%earth%'
    filter is not working.

    Code:
    SELECT programs.*, programComments.* FROM programs INNER JOIN programComments ON programComments.commentBy = programs.programManager WHERE programComments.comment LIKE '%earth%'
    Any help is appreciated

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,334
    It's hard to be sure without understanding your data schema, but I suspect it's the nature of the inner join: you will get a result row for every matching join between the two tables (i.e.: every match for the ON clause). How to solve that will depend on exactly what you are trying to do and the actual data structure -- perhaps only selecting the exact fields you need (instead of "*") and using a DISTINCT would do the trick, but that's pure speculation at this point.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

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