Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 8:11 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Database Query - SQL Search String
PostPosted: July 12th, 2007, 1:10 pm 
I am trying to create a query for all surnames beginning with a certain letter, I have setup the query and used the equal to with a Compare to String value..but what do I enter for all entries beginning with W?


Top
   
 
 Post subject:
PostPosted: July 12th, 2007, 2:29 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
var RecSet = db.ExecuteSQL("SELECT * FROM tablename WHERE fieldname LIKE '%"+mySearch+"%'")

The above will match any wildcard - EG if there is a W in the field.

Remove JUST the left % to match W at the start of the field.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: July 20th, 2007, 12:01 pm 
Offline

Joined: May 24th, 2007, 11:02 am
Posts: 132
Location: UK - Wales - Ceredigion
Opus: illuminatus > Evolution
OS: Windows 10 Pro
System: i7 8GB RAM
This would solve a problem that I also have, but where and how would you use this script in opus?

As far as I can see you only have the option of using the SQL Wizard? or script in another window?


Top
 Profile Visit website  
 
 Post subject:
PostPosted: July 20th, 2007, 1:10 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Jez,

Not quite sure what your getting at...but I pull this example from a DB application that I use. Records are displayed on screen in array elements to create a list.

At the bottom is a search box, enter the term and click return passes this to a function that retrieves (select statement) the dataset based based on the filter. This dataset then populates the existing array - thus displaying my filter list.

Hope this helps.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: July 20th, 2007, 1:31 pm 
Offline

Joined: May 24th, 2007, 11:02 am
Posts: 132
Location: UK - Wales - Ceredigion
Opus: illuminatus > Evolution
OS: Windows 10 Pro
System: i7 8GB RAM
Hi Mack

Thanks for the reply

I have been using the access database example that came with the software.

If I insert a new page before the example, insert a user text box, save this variable then add a search button (which is really a go to next page), then on the given example page I want to amend the query so that it takes the saved variable and adds a % before and after so that only the searched results are shown.

Task : amend access example to provide user with a search box.

I hope this makes sense.


Top
 Profile Visit website  
 
 Post subject:
PostPosted: July 20th, 2007, 4:26 pm 
Offline

Joined: May 24th, 2007, 11:02 am
Posts: 132
Location: UK - Wales - Ceredigion
Opus: illuminatus > Evolution
OS: Windows 10 Pro
System: i7 8GB RAM
for what I wanted I have just worked it out.

If anyone else wants to do this then a carry on from my last post...

On the second page where the results are shown, add a script to the page's action list that contains:

Code:
V2 = "%" + V1 + "%";

In this example V1 was from the first page (user input / search text) and V2 is a new temp variable.

We can now use V2 to search.

I hope this makes sense now.


Top
 Profile Visit website  
 
 Post subject:
PostPosted: July 21st, 2007, 10:40 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
That would work :-)

Also don't know what you DB application is for, but if the search is an important function and you want flexability, then you could have the user include a wildcard.

IE they enter %ing% or %ing or ing% or simply ing

This would allow you to perform more specified searches, but would depend on your audinace and whether the understood the wildcard concept.

This may lead on to using the other SQL wildcards.

Mack,

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 44 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group