Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Search with 4 params

 
Philip Pross
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,
I have a question towards sql, I have a search engine with 4 params. Meaning the using can do a search on 1 thing, 2 or even all 4 things, the search contains a first name, last name, city, and country. And with this, there is a number id for each person, so in theory is a user looks for a person with the last name WOOD (returns id 2, 4, 9), and location is CANADA ( returns 1, 2, 11), there should be only one result id number 2.
thanks Phil
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Phil
In a SQL SELECT statement you can add more than one condition in the WHERE clause using logic operators AND and OR.
So your query might be something like this:
SELECT * FROM myTable WHERE firstName like "Bob" AND lastName like "Smith" and location like "Canada"
Now it'll only select people named Bob Smith who live in Canada. You can even group the conditions with ().
Hope that helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic