SQL Query Wildcard

1723
3
07-21-2011 09:47 AM
deleted-user-K_IRAXrpGKsG
New Contributor III
Hello,

I'm writing an SQL query that is used in an HTML drop menu.

The problem is trying to run a query that selects all values.

Here is query i've tried running :

eventTypeSQL = "Type = ''*" ;


This isn't working. Is there a way to select all in a database using a wildcard, or is there another method.

Thanks in advance!
-Pat
0 Kudos
3 Replies
derekswingley1
Frequent Contributor
Depends on the underlying datastore. The where property of a query gets passed through to the database. To get all values, you could use:
query.where = '1=1';


This will return all values until you hit the max results for your map service (at 9.3, it's 500 records, at 10, it's 1000 records).

If you don't want to use the 1=1 approach, watch out for string formatting...be sure you have all your single and double quotes in the right place.
0 Kudos
deleted-user-K_IRAXrpGKsG
New Contributor III
Thanks for replying, I'm not sure if the 1=1 option will work.

I have three event types: Conference, Lecture, Workshop.

There is a drop menu that allows the user to choose one of those three, but I would also like the user to be able to search for all three at the same time essentially looking at every possible record in the database on the map at once.

So, I would like the user to choose "All Events" from the menu and populate the map with Conferences, Lectures and workshops.

How would I do that with the SQL code?

Obviously  eventTypeSQL = "Type = '*' " doesn't work. Any ideas?
0 Kudos
derekswingley1
Frequent Contributor
This sounds like a basic SQL question. If you want to search for a specific event type, add that to your where clause:
query.where = 'someField = "someValue" AND eventType = "Conference"'


Otherwise, just leave the eventType out of your where clause. If there's nothing to filter your data, use query.where = '1=1'.
0 Kudos