sql server - Syntax error when using OFFSET, ORDER BY (Bit and Date DESC) and WHERE in my SQL Query -


i have news article database tblnewsevents so:

newsid  |  newssticky   |   newsdate              |   newscontent --------+---------------+-------------------------+--------------- 1       |   true        |   10/09/2017 18:05:22   |   varchar text 2       |   false       |   10/09/2017 18:00:53   |   varchar text 3       |   false       |   10/09/2017 18:04:18   |   varchar text 4       |   false       |   10/09/2017 18:03:57   |   varchar text 

and table, user can upload images news story. adds newsid of story newssyncid column in tblnewseventspic database knows story , images connected.

picid   |  picone       |   pictwo      |   syncnewseventid --------+---------------+---------------+------------------- 1       |   /path.jpg   |   /path2.jpg  |   1 2       |   /path.jpg   |   /path2.jpg  |   2 3       |   /path.jpg   |   /path2.jpg  |   3 4       |   /path.jpg   |   /path2.jpg  |   4 

how can sort through newsdate desc , newssticky = true/1 recent stories and/or news sticky stories @ top?

i same syntax error near where, no matter how try , phrase query.

select *  tblnewsevents  left join tblnewseventspic on tblnewsevents.newsid = tblnewseventspic.syncnewseventid  order newsdate desc      offset 1 rows  newssticky = 1; 

offset 1 rows enabled recent news story featured elsewhere.

i use left join picture path picone used alongside news article.

but sorting bit proving challenge.

trying find help online, syntax error searched 'how use offset , where' articles not helpful.

the correct syntax is:

select * tblnewsevents left join      tblnewseventspic      on tblnewsevents.newsid = tblnewseventspic.syncnewseventid  newssticky = 1 order newsdate desc  offset 1 row fetch next 10 rows 

the order of clauses matters.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -