Results 1 to 4 of 4
  1. #1
    ABW Ambassador Greg Rice's Avatar
    Join Date
    January 18th, 2005
    Location
    Ohio
    Posts
    4,889
    What is the best way to query a mySQL database to display information that matches two criteria. When I use AND in my query it fails. Each criteria by itself produces results but no results used together. I tried many ways but can't understand why this query won't work.

    SELECT *
    FROM DatabaseName
    WHERE Price < '1000.00' AND PriCategory LIKE '%WordsInACategory%'
    ORDER BY TigerDirect.Price

    When I run the WHERE Price < '1000.00' query I get results and when I run the PriCategory LIKE '%WordsInACategory%' I get results, so why don't I get any results when both are used?

  2. #2
    ABW Ambassador sjangro's Avatar
    Join Date
    January 18th, 2005
    Location
    Boston
    Posts
    1,529
    That looks ok to me.

    You may not need the quotes around the 1000.00 if you have price defined as a numeric field.

    What is the error message?

    --
    Scott Jangro
    sjangro@befree.com

  3. #3
    ABW Ambassador sjangro's Avatar
    Join Date
    January 18th, 2005
    Location
    Boston
    Posts
    1,529
    I just tried this on the tiger datafeed loaded into MySQL and it worked fine.

    SELECT *
    FROM tiger
    WHERE retail_price < '1000.00'
    and primary_cat like '%network%'
    ORDER BY tiger.retail_price

    The quotes on the price don't matter. It works either way.

    --scott

    --
    Scott Jangro
    sjangro@befree.com

  4. #4
    ABW Ambassador Greg Rice's Avatar
    Join Date
    January 18th, 2005
    Location
    Ohio
    Posts
    4,889
    Thanks much! You're good. The select statement was ok but I had price set to varchar. I changed it to decimal and the statement works now. After about 3 hours of playing with it...

    Anyway, thanks again. I wanted to do a sort of TD systems by price and needed to have both requirements. Appreciate it!! [img]/infopop/emoticons/icon_biggrin.gif[/img]

  5. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Nested IF statements -why don't they work?
    By sotonman in forum WebMerge (Fourthworld.com)
    Replies: 6
    Last Post: August 16th, 2006, 06:55 AM
  2. Nesting Multiple IF statements?
    By sholto in forum WebMerge (Fourthworld.com)
    Replies: 1
    Last Post: August 5th, 2005, 02:59 AM
  3. Zango does not run by their own statements
    By Allen Nance in forum Suspicious Activity!
    Replies: 7
    Last Post: April 4th, 2005, 08:30 AM
  4. Reporting is down & Affiliate Statements are gone to!
    By ~Michelle in forum Rakuten LinkShare - LS
    Replies: 14
    Last Post: December 26th, 2003, 08:19 AM

Posting Permissions

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