Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7488961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:07:08+00:00 2026-05-29T15:07:08+00:00

I have this table pageview id | visitor | id_realestate | time ———————————————– I

  • 0

I have this table pageview

 id    |   visitor   |   id_realestate  |   time
 -----------------------------------------------

I want the record to be inserted if only the last time is 30 mins old at least for that particular id_realestate which has been checked by that particular visitor

update

to make it clearer. If I have this data ready to be inserted in the table

visitor:"axax"
id_realestate:120
time:NOW()

these value should be inserted if only the last record with these values visitor:"axax" & id_realestate:120 is older than 30 minutes (by checking the field time for the last record of the two values I mentioned and compare it with NOW() if the difference is greater than 30 minutes. if so then the data should be inserted)

update

I have this these data now. as you can see the time field contains a value from yesterday so any new data should be inserted:

enter image description here

I used this query as suggested by anubhava but nothing happened ( no new record added/ no errors)

$query='insert into pageview
select "q17872745t", 150, now() 
from pageview a
where id_realestate=150 and DATE_ADD(now(),INTERVAL -30 MINUTE) > (
  select max(time) from pageview b where a.id_realestate=b.id_realestate AND   a.visitor=b.visitor
)';

update

I modified the query to the following and it’s working BUT It compares with every time if the latest time is 30 mint old and accordingly it inserts a record( meaning it doubles the records). so if I have two records with same visitor and id_realestate it will compare with these two records if the time in both is 30 minutes old then it inserts 2 identical records whereas it should insert one record.

      $query='insert into pageview (visitor,id_realestate,time)
      select "q17872745t", 150, now() 
         from pageview a
         where id_realestate=150 and DATE_ADD(now(),INTERVAL -30 MINUTE) > (
            select max(time) from pageview b where a.id_realestate=b.id_realestate AND a.visitor=b.visitor
      )';

update: [solved]

I added LIMIT 1 at the end of the above query, now it’s working as it should. here is the final query:

      $query='insert into pageview (visitor,id_realestate,time)
      select "q17872745t", 150, now() 
         from pageview a
         where id_realestate=150 and DATE_ADD(now(),INTERVAL -30 MINUTE) > (
            select max(time) from pageview b where a.id_realestate=b.id_realestate AND a.visitor=b.visitor
      ) LIMIT 1';
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T15:07:10+00:00Added an answer on May 29, 2026 at 3:07 pm

    Not a very clear question but you can use a query like this: (untested)

    insert into pageview
      select 15, 'A VISITOR', 10, now() 
      from pageview a
      where id_realestate=10 and DATE_ADD(now(),INTERVAL -30 MINUTE) > (
          select max(news_release) from pageview b where a.id_realestate=b.id_realestate
      );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this table on MySQL. I want to query the port number for
I have this table: old_id integer NOT NULL, new_id integer Now I want to
I have this table in an Oracle DB which has a primary key defined
I have this table CREATE TABLE [dbo].[friend_blocked_list]( [subdomain] [varchar](50) NOT NULL, [un] [nvarchar](50) NOT
I have this table CREATE TABLE `codes` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
i have this table in UTF8 (collation is utf8_bin in case it matters). I
I have this table: CREATE TABLE `test` ( `ID` int(11) NOT NULL auto_increment, `text`
I have this table: fourn_category (id , sub) I am using this code to
I have this table: CREATE TABLE `point` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `siteid`
I have this table: id feed_id ... Let's say that I have 500 rows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.