Print

Print


How might I write an SQL query to find all the descriptions of good kings and bad kings in my database?

I have a table that looks something like this:

  key  word       part_of_speech  position
  ---  ---------  --------------  --------
  w1   The        article         1
  w2   righteous  adjective       2
  w3   king       noun            3
  w4   solved     verb            4
  w5   all        adjective       5
  w6   the        article         6
  w7   problems   noun            7
  w8   Your       noun            8
  w9   evil       adjective       9
  w10  king       noun            10
  w11  over       adverb          11
  w12  taxes      verb            12
  w13  us         pronoun         13

And I want to list how kings are described. In this example, kings are both righteous as well as evil. How can I implement this in pure SQL? How do I find all words where the given word is "king" and the previous word is an adjective?

—
Eric Morgan