Select Statement Problem

# Thread: Select Statement Problem

1. Junior Member
Join Date
Dec 1969
Posts
2

## Select Statement Problem

I am trying to select records in a range based upon the square footage of a building.<BR><BR>I have three buildings with square footage of 589, 750 and 1190<BR><BR>With the following statement, I get the 1190 property record returned:<BR>rsProperties.Source = "SELECT * FROM tblProperties WHERE <BR>Sqft &#062; &#039;" & "1100" &"&#039; AND Sqft &#060; &#039;" & "1200" &"&#039;<BR><BR>With this statement, I get the 589 and 750 sqft property records returned.<BR>rsProperties.Source = "SELECT * FROM tblProperties WHERE <BR>Sqft &#062; &#039;" & "550" &"&#039; AND Sqft &#060; &#039;" & "999" &"&#039;<BR><BR>However, with this statement, I get no property records returned and I should get all three:<BR>rsProperties.Source = "SELECT * FROM tblProperties WHERE <BR>Sqft &#062; &#039;" & "550" &"&#039; AND Sqft &#060; &#039;" & "2000" &"&#039;<BR><BR>Can someone advise me of where I went wrong?<BR><BR>Will

2. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: Select Statement Problem

I bet your field sqft is textuaral!<BR><BR>if you change it to numeric this will work<BR><BR>and remember the query does not need the " in them then

3. Senior Member
Join Date
Dec 1969
Posts
178

## what happens when....

you say Select * from tblProperties ???<BR><BR>Do you see all results??

4. Member
Join Date
Dec 1969
Posts
93

## RE: Select Statement Problem

It looks to me like your doing a character comparison...<BR><BR>"550" is &#062; "2000"<BR><BR>Hope this helps<BR><BR>Elija

5. Junior Member
Join Date
Dec 1969
Posts
2

## RE: Select Statement Problem

Thanks!<BR>I changed it to a numeric field and it worked, however, now I&#039;m trying to add a form variable to place in the statement and getting an error:<BR><BR>SQFT1 = Request.Form("lowsf")<BR>SQFT2 = Request.Form("highsf")<BR><BR>rsProperties.Source = "SELECT * FROM tblProperties WHERE Sqft &#062;= &#039;" & SQFT1 &"&#039; AND Sqft &#060;= &#039;" & SQFT2 &"&#039;<BR><BR>Microsoft OLE DB Provider for ODBC Drivers error &#039;80040e07&#039; <BR><BR>[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. <BR><BR>/ct_property_search2.asp, line <BR>

6. Senior Member
Join Date
Dec 1969
Posts
11,247

## Should be

"SELECT * FROM tblProperties WHERE Sqft &#062;= " & SQFT1 &" AND Sqft &#060;= " & SQFT2 <BR><BR>OR<BR>"SELECT * FROM tblProperties WHERE Sqft Between " & SQFT1 &" AND " & SQFT2

#### Posting Permissions

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