Results 1 to 10 of 14

Thread: MYSQL Query

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    jamison is offline Nearly a Glow Sage
    Join Date
    Jun 2005
    Posts
    20

    Default

    Yes, I really do want to do this and thank you for your reply. However, I am getting some unusual results. My query is
    SELECT *
    FROM master_stock
    WHERE symbol = 'BA'
    OR symbol = 'BAC'
    OR symbol = 'BMY'
    OR symbol = 'CAT'
    AND dtime
    BETWEEN '2009-09-08 9:00'
    AND '2009-09-08 17:00';

    The last symbol is dropped from the report and the report begins at the first day of the data base, not on Sept, 8th. Any ideas. I really appreciate the help.

  2. #2
    Dmitriy is offline Nearly a Master Glow Jedi
    Join Date
    Feb 2007
    Location
    Ukraine
    Posts
    124

    Default

    This one is complete correct example

    PHP Code:
    SELECT 
    FROM master_stock
    WHERE 
    (symbol 'BA' OR 
    symbol 'BAC' OR 
    symbol 'BMY' OR 
    symbol 'CAT') AND 
    dtime BETWEEN '2009-09-08 9:00' AND '2009-09-08 17:00' 
    For simplycity I'd suggest you omit BETWEEN and use only logic operands

    PHP Code:
    SELECT 
    FROM master_stock
    WHERE 
    (symbol 'BA' OR 
    symbol 'BAC' OR 
    symbol 'BMY' OR 
    symbol 'CAT') AND 
    dtime >= '2009-09-08 9:00' AND 
    dtime <= '2009-09-08 17:00' 
    The trick is in brackets where you put your OR's.

Similar Threads

  1. Replies: 26
    Last Post: 02-01-2008, 08:17 PM
  2. Replies: 0
    Last Post: 04-21-2005, 09:13 PM

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14