Select to view content in your preferred language

SELECT WHERE statement

3513
12
08-16-2010 09:40 AM
JayKappy
Frequent Contributor
I can get this query to work...but its quering a Double Field (ANGLE):

' Build Query Statement
Dim varQuery
varQuery = "SELECT OBJECTID FROM SIGNS_STANDALONETABLE WHERE ANGLE = 270"

' Set up recordset query
Dim  pRS6
Set pRS6 = pDS6.Execute(varQuery)

' Move first
pRS6.MoveFirst
        
Do While Not pRS6.EOF 
 Dim MaxID, MaxID2   
 MaxID = pRS6.Fields("OBJECTID").Value
 MaxID2 = MaxID2 & ", " & MaxID
 pRs6.MoveNext 
Loop

msgbox "Max ID: " & MaxID2


But I need to query a string field and I cant get that to work....this is what I was trying:
ID is a text field in the table

varQuery = "SELECT OBJECTID FROM SIGNS_STANDALONETABLE WHERE ID = "01NW-001" "

I then wrote it to a variable and tried this:
Dim varUniqueID 
varUniqueID = "01NW-001"
varQuery = "SELECT OBJECTID FROM SIGNS_STANDALONETABLE WHERE ID = " & varUniqueID & " "

neither works....any thoughts?

THanks in advance....
Tags (3)
0 Kudos
12 Replies
JayKappy
Frequent Contributor
OH man do i feel stupid....OK the query seems to be workign now although back in ArcMap I am not zoomed to full extent therefore not all of my data is being exported...I think this is that last issue...
0 Kudos
JayKappy
Frequent Contributor
Last question...

How do I get this to work with a varaible...I tried this: 

varQuery = "SELECT * FROM SIGNS_STANDALONETABLE WHERE Support_ID1 = " & varUniqueID & " "

and This

varQuery = "SELECT * FROM SIGNS_STANDALONETABLE WHERE Support_ID1 = ' & varUniqueID & ' "

and This

varQuery = "SELECT * FROM SIGNS_STANDALONETABLE WHERE Support_ID1 = ' " & varUniqueID & " '  "

varQuery = "SELECT * FROM SIGNS_STANDALONETABLE WHERE Support_ID1 =  " & varUniqueID
0 Kudos
JayKappy
Frequent Contributor
I swear ArcpAD is really flaky....

varQuery = "SELECT * FROM SIGNS_STANDALONETABLE WHERE SUUPORT_ID1 = '"& varSupportID &"' "

This now works...and was one of my previous attempts that didnt.....

THANK YOU ALL FOR YOUR HELP....VERY APPRECIATED... maybe its the elimination of spaces???  '"& varSupportID &"' "


IT WAS THE SPACES THAT WAS MESSING THINGS UP....

Not working:   ' " & variable & " '

Working:        '"& variable &"'

Go figure
0 Kudos