Results 1 to 2 of 2

Thread: SQL Query returning to many results

  1. #1
    Join Date
    Apr 2012

    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
    WHERE programComments.comment LIKE '%earth%'
    filter is not working.

    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
    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.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

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