Gossamer Forum
Home : Products : DBMan SQL : Discussion :

SQL Question...

Quote Reply
SQL Question...
OK I need some help here. I don't know if I'm doing something wrong. In the flat file DBMan, on the search page I could type B* in a field like "Last Name" and get back all the "Last Name" starting with B. It doesn't seem to work the same way in DBManSQL. It returns ANY last name that has a B in it! I've tried B* B%, with and without Whole Word (WW). What's the deal here...what do I have to do?

I've had other users ask how to search for their Marine units like HMH-162. Some people put it in the database as HMH162 or HMH 162 or HMH-162. With htgrep, you could type HMH*162 and get back all 3 different ways in one list. For now, I had to tell them to do an individual search for each way.

Any help would most definetely be appreciated!

AJ

Quote Reply
Re: SQL Question... In reply to
Try using:

^B

Then select regular expression.

Regards,

Eliot Lee
Quote Reply
Re: SQL Question... In reply to
I too am interested in this. The suggestion you offered doesn't work for me. Any other ideas?

Quote Reply
Re: SQL Question... In reply to
I've come up with a solution for searching for all things that start with whatever. Like I type in Z* in my Last Name field and I get all last names that start with Z instead of everything that has a Z in it. Then I choose to sort by Last name ascending and I get an alphabetical list of last names starting with Z. Here is what I did:

Code:
In db.cgi
sub query

----Change:
# We are looking at strings.
if ($in{$field} eq "*") {
$where .= qq!
$field $comp '%' $bool!;

----To:
# We are looking at strings.
if ($in{$field} =~ /\*/) {
$in{$field} =~ s/\*/$1\%$2/g;
$where .= qq!
$field $comp '$in{$field}' $bool!;
You can still put a * in the field and get all results back from that field. You can also put *Z* to get back everything with a Z in it...but I guess it would be easier to just put a Z in the field to get this result. I still don't have a solution for HMM2 returning HMM162, HMM-162, and HMM 162 all at the same time.

I can't and don't want to believe that htgrep is better than SQL at searching and search options. The damn manual at www.mysql.com just got converted to an easier to read, but a pain to navigate docs for MySQL. The old docs had the 'LIKE (with variables)' section, but I can't get to it in the new docs.

Anyway, hope this helps.

AJ