Mysql order by timestamp (and keep event at top of results if date is within two weeks) -


I am writing a query that pulls data from different tables (user activity stream)

' Events EventData 'below is the actual date of the event in YYYY-MM-DD - Timestamp is the time posted.

I write your query by ordering timestamp but push event to top if event date two weeks?

  select events.user_id, to do within the events. Eventdate_us, events.start_time, events.event_title, events.description, events.venue, events.add1, events.city, events.country, events.website, 'zero' update_msg, 'zero' buy_selling, 'zero' Users.user_id = events on the left as in the form of 'events' as stock_type, events.timestamp as timestamp, source, users.contact_person, users.company, users.pic_small, users.pic_large. Timestamp DESC limit 30   

based on user_id command users should add that this is part of some union calls to get everything I need the query below

I'm trying to get what (event within the top two weeks) - I eventdate_us = '2014-07-31' DESC, timestamp DESC can get this with order limit 30 but I have to specify the exact date.

Enter image details here

What do I want to do All events will occur within weeks, as some orders ORDER BY eventdate_us & lt; NOW () + INTERVAL DESC for 14 days, Timestamp DESC limit 30

Except that it does not work and

 Enter the image details

This was more like eventdate_us by order = (eventdate_us> = (DATE_ADD (NOW), interval 14 days))) ASC, timestamp DESC limit 30 ");

Although this is not perfect because still not selecting a date within two weeks (I.e. the future date is more than two weeks.)


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -