php - composing mysql query for viewed notifications -


i writing notification alert functionality. have a table notification there field viewed. value of viewed tinyint. when user views notification flipped 1. based on viewed display notfications ready alert. in case there no new er notification want display viewed notification. query used

$query="select * notification notifierid=? , viewed=0 order notificationdate desc "; 

now want in pseudo language

select fields notification notifierid=someid , viewed=0 incase  there new notifications retreive old viewed=1 if new notifications less 10 ordered date 

please let me know if there way it. thanks

i think might interested in this:

select     *     notification     notifierid=? ,     viewed in (0, if((select count(*) notification viewed = 0)<10,1,0)) order     viewed asc,     notificationdate desc 

this cause non-viewed notifications on top sorted date descending , viewed notifications show date descending.

i hope able understand question if not please let me know.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -