Deenath Kumar Deenath Kumar - 6 months ago 10
SQL Question

this sql made me little complex situation

Hi sql'ers though am dealing with SQL from past 4 years. I encountered little complex situation today.

I have a mysql table with columns, id,movieid,Lang,comment, and timestamp so i want to render comment for a particular movie in which user can decide a range that from where to where he wants a comment for that particular movie but when i try the following query will not working out. So help me guys I'm stucked.

SELECT comment from aaa where movieid=2 and language='en' between6 to 10


Here basically I need to fetch from 6th comment to 10th comment from my aaa table (only for passed movieid parameter). All help will be appreciated.

Answer

As far I understand you need to fetch 4 comments in total (between 6th and 10th) so you want to use LIMIT for that, starting from 6th record:

SELECT
    `comment`
FROM
    aaa
WHERE
    movieid = 2
AND `language` = 'en'
LIMIT 6,4