20706

New records since last query in MySQL View

Question:

I am looking for a way to create a View that when queried will automatically only retrieve new records since the last query. My tables have a timestamp field for all entries, so for a simple example I can

SELECT * WHERE timestamp >= 'blah'

but I don't know how to determine what blah should be from the last query. So if the View was queried at 11:00 and then again at 12:00, the query at 12:00 should only return records added since 11:00. And so on... This all needs to be accomplished in the View, the end user should simply be able to query the View and get the results.

Is this possible?

Answer1:

There are two ways:

<ol><li>

Store last access date time in database per user persistent session table, if you have one. On next view call to database, use the previous latest access time in the session to filter rows starting from.

</li> <li>

Store last access date time in user virtual session at client environment. On every call to server, send last access date time as well. So that server uses it to filter rows starting from.

</li> </ol>

I prefer to use second option that process won't write any data in database tables.

Recommend

  • How should I store date/time objects in SQL?
  • ocaml llvm kaleidoscope tutorial “Unbound module LlvmExecutionEngine”
  • In java, what time is the start of the day?
  • Unix timestamp to iso 8601 time format
  • Scroll to anchor link in a Sammy.js project
  • How do I use SFSafariViewController with a dark theme like this user?
  • Grunt module(s) to upload all static assets to S3 / CloudFront, replace paths, and invalidate old as
  • How to do popup on new site for 301 redirected users?
  • $this->params returns null in cakephp model
  • JPA/Hibernate - Entity name seems to be important. If I rename to “Bob” works fine
  • How to determine the CCSID used in CPYFRMIMPF command?
  • How to discover Font Type?
  • How do I include a SWC in an AS2 Flash project?
  • Tamper-proof configuration files in .NET?
  • Is playing sound in Javascript performance heavy?
  • How to define and use opencv mat of user type
  • Test if a set exists before trying to drop it
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • How to rebase a series of branches?
  • How do I change content of ComboFieldEditor?
  • Insert into database using onclick function
  • Cassandra Data Model
  • Knitr HTML Loop - Some HTML output, some R output
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Javascript + PHP Encryption with pidCrypt
  • Weird JavaScript statement, what does it mean?
  • Do I've to free mysql result after storing it?
  • WOWZA + RTMP + HTML5 Playback?
  • SQL merge duplicate rows and join values that are different
  • Getting Messege Twice Using IMvxMessenger
  • How does Linux kernel interrupt the application?
  • Django query for large number of relationships
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • How can I use `wmic` in a Windows PE script?
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • Python/Django TangoWithDjango Models and Databases
  • How to push additional view controllers onto NavigationController but keep the TabBar?