Easy (?) Access SQL question

Discussion in 'Software' started by shedlord, Apr 12, 2005.

  1. shedlord

    shedlord Private E-2

    Scenario: Someone at work has an Access database she fills in daily. We need to design a query that filters on a number field called 'Week_Number' so that records are only shown if they are between 2 weeks that the user is prompted to give.

    A query was built which has a WHERE clause that goes...

    WHERE ((([blah].Week_Number)>[Week greater than] And ([blah].Week_Number)<[Week less than])

    But it doesn't seem to work properly and I don't get why. Eg. If you put 2 in for 'Week greater than' and 8 in for [Week less than] it will still show you results with 'week_number' values outside that range.

    What am I doing wrong here?

    Thanks.
     
  2. Kodo

    Kodo SNATCHSQUATCH

    where tablename.weeknumber between [@var1] and [@var2]
     
  3. shedlord

    shedlord Private E-2

    Ok, sorry folks but this turned out to be a basic error on my part. The SQL statement above was taken from an earlier version of the database. Extra criteria had been incorrectly applied to the one that was going wrong - a case of me misunderstanding how the Query design view worked.

    I'll stick to writing them out in SQL view in future!
     
  4. Kodo

    Kodo SNATCHSQUATCH

    I would still try the between function instead of having the db engine evaluate a value size; it can just check if the value is in range. It might help optimize things a bit... just a bit. ;)
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds