Skip to content

SQL : select values between multiple ranges

I have a table like the one below… ID Price ==== ====== 1 1000 2 2000 3 4000 4 5000 Now I need a query to select values between 500 and 1500 And between 2500 and 4500. i.e. like …

Sqlite get max id not working (?)

Im using this: But my query is empty. I have also tried this (This one works): But obviusly my query only contains the max_id key. What am I doing wrong with the first one? Answer You need to add another level of select for the MAX, like this: A better approach would be to order by id in descending order,

How can a query select dates from only a specific academic year?

This may be simple, but I cannot figure out the correct and simplest way to query a table which contains a date col to return the rows in which the date belongs to the current academic year. Knowing that for academic year I mean the period from the 1st of September of a year to the 31st of august of

MySQL Query join last comment to topic

I have a topic and topic_comments table. I want to join them both. The join is on topic.id = topic_comments.parent_id. I want to show the topic with latest comment and order by latest comment createdate. And not show duplicate topics. Can anyone help me? So far I have this: This however doesn ‘t show to…