Building advanced SQL search from a user text input

We are going to build a program that parses user search query and serializes it into a SQL statement. Here is an example of a search query:

What this says is:

  • Find records with first name “Thomas”
  • Exclude mentions of “jefferson”
  • Narrow down results to where the birthdate is between 1960 and 1970
  • Narrow down results to where the profession is either “inventor” or “engineer”
Designing SQL search

In SQL, this could look something like:

It might not be the most succinct form of SQL to do the job, but it is good enough.

https://contra.com/p/WobOBob7-building-advanced-sql-search-from-a-user-text-input

--

--

Founder, engineer interested in JavaScript, PostgreSQL and DevOps. Follow me on Twitter for outbursts about startups & engineering. https://twitter.com/kuizinas

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gajus Kuizinas

Founder, engineer interested in JavaScript, PostgreSQL and DevOps. Follow me on Twitter for outbursts about startups & engineering. https://twitter.com/kuizinas