Please suggest query and table structure for this

Discussion in 'MySQL' started by JEET, May 6, 2009.

  1. #1
    Hi,
    I am currently using the following table structure:
    id, customerid, date_time_stamp, logged_in

    The following query goes here:
    select customerid from table where customerid='100' and date_time_stamp='sometime'
    So if have to check for 3 dates (9may, 10may, 11may), I need to run 3 different queries
    I was hoping if someone could suggest some other queries so I can check if this customer was llogged in in 3 different dates with 1 query, or something similar.

    I can change the table structure as well if needed. Any suggestion is useful cause I think I'm using the worst method right now...
    Thanks :)
     
    JEET, May 6, 2009 IP
  2. taarzan

    taarzan Active Member

    Messages:
    240
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #2
    my suggestion to you is select date_time_stamp from table where customerid='100'
    it will return all the dates for the mentioned customer id hope it will do the trick for you.
     
    taarzan, May 7, 2009 IP
  3. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #3
    Yes, that will get me all dates, but that will be a lot of memory usage because some members are logged in everyday (and as the site gets older, this will slow the server a lot), and I just need to check if this particular member was logged in in a certain date range. Ex: 9may to 11may (3 days)

    I was thinking about a query like:
    "select date from table where customerid='100' and (date='9' or date='10' or date='11' ) ";
    but for some reason I think that is not as accurate as the method I am currently using.

    Anything else I can do?
    Thanks :)
     
    JEET, May 7, 2009 IP
  4. taarzan

    taarzan Active Member

    Messages:
    240
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #4
    then i suggest you to use a combo boxes and the query will be >> select date from table where customerid='100' and (date >="+combobox1.text+" && date <="+combobox2.text+" ) , hope this will solve ur problem.
     
    taarzan, May 7, 2009 IP
  5. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #5
    koko5, May 7, 2009 IP
  6. robertstr

    robertstr Member

    Messages:
    218
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #6
    robertstr, May 10, 2009 IP