Pregunta

In SQL, you can use cast or convert to convert a string to an integer so you can compare numerical values, i.e.

SELECT * FROM table1 WHERE CAST(col1 AS int) < 100

Is it possible to do the same thing in YQL?

The following doesn't work:

SELECT * FROM json WHERE url='url_goes_here' AND CAST(col1 AS int) < 100

It gives me 0 results. I should be getting more.

In both queries, col1 is a string.

¿Fue útil?

Solución

YQL is not exactly SQL per say. It is a "SQL like" language. It does not query a database instead in the background makes REST calls to the backends.

Since I don't know what table you are querying, from what I understood from the question, what you are saying can be achieved. Read the yql doc here. Sample query select * from local.search where query="sushi" and location="san francisco, ca" and Rating.TotalRatings < "12"

I know its strange that we are comparing against a string value but it does work. You can test this on the YQL console here (just copy paste the query in the text box). Let me know if you have any questions/concerns. I will try to answer it to best of my knowledge.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top