Link to home
Start Free TrialLog in
Avatar of darrellbuckley
darrellbuckley

asked on

Select Statment

Im trying to pull my 5 and 6 year olds from a table with this code but it seem to be selecting all the records instead of just the ones from 2011, anyone notice whats wrong?

SQLStmt =  "Select COUNT(*) AS FiveSix"
SQLStmt = SQLStmt & " From ""Reg"" "
SQLStmt = SQLStmt & "Where ""LEAGUEAGE"" = '" & 5 & "' OR  ""LEAGUEAGE"" = '" & 6 & "' AND ""NEWYEAR"" = '" & 2011 & "'"
Avatar of darrellbuckley
darrellbuckley

ASKER

Sorry Wrong Code this is the one..

      SQLStmt = "Select ""ID"", ""PFNAME"", ""PLNAME"", ""BIRTHDATE"", ""SIBNAME"", ""LEAGUEAGE"" , ""LEAGUE"""
      SQLStmt = SQLStmt & " From ""RegForm2009"" "
      SQLStmt = SQLStmt & "Where ""LEAGUEAGE"" = '" & 5 & "' OR  ""LEAGUEAGE"" = '" & 6 & "' AND ""NEWYEAR"" = '" & 2011 & "'"
      SQLStmt = SQLStmt & " ORDER BY ""PFNAME"" ASC; "
ASKER CERTIFIED SOLUTION
Avatar of derekkromm
derekkromm
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, posted for the original query. Wrap the age=5 or age=6 with parentheses.


SQLStmt = "Select ""ID"", ""PFNAME"", ""PLNAME"", ""BIRTHDATE"", ""SIBNAME"", ""LEAGUEAGE"" , ""LEAGUE"""
      SQLStmt = SQLStmt & " From ""RegForm2009"" "
      SQLStmt = SQLStmt & "Where (""LEAGUEAGE"" = '" & 5 & "' OR  ""LEAGUEAGE"" = '" & 6 & "') AND ""NEWYEAR"" = '" & 2011 & "'"
      SQLStmt = SQLStmt & " ORDER BY ""PFNAME"" ASC; "
SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the replies but I noticed that I was'nt even pulling the NEWYEAR field, seems to be working now. Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial