Hello there -
I am trying to get a where clause to work and haven't been very successful. I'm hoping someone here will be able to shed some light on the subject. Here is the example and source for my logic:
I have a column family with 5 columns: veggies, fruits, drinks, var1 and var2. I want to find all of the rows where veggies ='carrots', fruits = 'apples', drinks = 'coke', and return all of that row's columns? So far what I have is the following:
row = session.execute('SELECT veggies as veggies, fruits as fruits, drinks as drinks FROM orders_archive WHERE ********)
I've tried multiple things and continue to get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/net/homedirs/sjones/lib/python2.6/site-packages/cassandra_driver-2.1.2.post-py2.6-linux-x86_64.egg/cassandra/cluster.py", line 1295, in execute
result = future.result(timeout)
File "/net/homedirs/sjones/lib/python2.6/site-packages/cassandra_driver-2.1.2.post-py2.6-linux-x86_64.egg/cassandra/cluster.py", line 2799, in result
raise self._final_exception
cassandra.protocol.SyntaxException: <ErrorMessage code=2000 [Syntax error in CQL query] message="line 1:117 no viable alternative at input 'drinks'">
My question is; can someone finish the line with the correct sentax needed to get the results I'm looking for? Here are just a few of the combinations I've tried using my source link as a guide:
- row = session.execute('SELECT veggies as veggies, fruits as fruits, drinks as drinks FROM orders_archive WHERE "carrots" in veggies, "apples in fruits, "coke" in drinks)
- row = session.execute('SELECT veggies as veggies, fruits as fruits, drinks as drinks FROM orders_archive WHERE (veggies,fruits,drinks) = ("carrots","apples","coke"))
- row = session.execute('SELECT veggies as veggies, fruits as fruits, drinks as drinks FROM orders_archive WHERE veggies = "carrots", fruits = "apples", drinks = "coke")
- row = session.execute('SELECT veggies as veggies, fruits as fruits, drinks as drinks FROM orders_archive WHERE veggies = "carrots" AND fruits = "apples" AND drinks = "coke")
I feel that I'm on the correct path, I just can't seem to figure out where my sentax is off. Thoughts? Thanks in advance for your help.