Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Managing And's & Or's in a SQL statement

Status
Not open for further replies.

Iainkerr01

Technical User
Joined
Aug 8, 2007
Messages
12
Location
GB
I am creating a query system for my users so that they can generate a result set for themselves.
The form has 4 columns as follows.
1. the 'Join' field (ie blank, and, or)
2. the search field name
3. the condition field (ie = , <>, Like)
4. the value of the field to search on.

The form will have up to 4 rows allowing the uses to create a more complex query involving "and's" & "or's". The query may not necessarily have all 4 rows filled.

The information from each of the rows will be added together to form a SQL statement.

The 'Join' field from row 1 will always be an 'And' as this will be linked to a general 'Where' statement.

Does anyone have a module already written which will help me manage the necessary bracketing within the SQL statement particularly where 'ors' are used?

Thanks in advance.
 
faq702-3619 shows details on dynamically building a where clause for a report selection. You can use this as a basis for your own needs.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top