Solved

MySQL soundex query help

Posted on 2007-11-20
1
523 Views
Last Modified: 2013-12-13
I have a search page with the following query that will return an exact match for a surname.  How do I adjust this query to allow for a check box, than when checked will return Soundex values. If it is left unchecked it returns an exact match. (i.e. this code returns all Snyders --  "Select Surname FROM database WHERE Soundex(Surname) = Soundex('Snider');"

Of course I want the user to be able to enter any surname, not just Snider!

Thanks Experts!
0
Comment
Question by:geist62
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 25

Accepted Solution

by:
imitchie earned 500 total points
ID: 20325471
will this work?
where @checked is whether or not the box is ticked,
 and @input is the surname being searched

Select Surname FROM database
WHERE
  (1=@checked and Soundex(Surname) = Soundex(@input)) or
  (0=@checked and Surname = @input)
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
The viewer will learn how to count occurrences of each item in an array.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question