SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: query problem

  1. #1
    SitePoint Addict
    Join Date
    Jun 2002
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    query problem

    Query problem. The version of MySQL that I am working with is 4.0.24 so I already know that I can't run subqueries. Here's my problem. I am running a small home improvement site and I need to pull just certain articles from the db. Here's the query that I use:
    PHP Code:
     $query "SELECT aid, article_title, article_text FROM articles WHERE article_type = 'article' AND keywords LIKE '%bath%' OR keywords LIKE '%kitchen%' ORDER BY article_title"
    The problem is that I need the article_type to be "article", but it's not processing the query like that. The last OR statement is killing me. How do I get around this?

    Thanks,
    Ian

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    parenthesis

    Code:
    WHERE
         article_type = 'article'
         AND (keywords LIKE '%bath%' OR keywords LIKE '%kitchen%')

  3. #3
    SitePoint Addict
    Join Date
    Jun 2002
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much! That worked perfectly.


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
  •