T
T
tupoi_nub2016-05-08 08:19:23
PHP
tupoi_nub, 2016-05-08 08:19:23

I need to write a postgresql query, can you help me?

Now I have a request

"SELECT id, extract(epoch from (now() - create_time::timestamp)) FROM ::users WHERE lastvisit IS NULL"
, Then I
foreach ($query as $value)
if ($value['date_part']>86400*3) \DB::query("DELETE FROM ::users WHERE id=?",[$value[id]]);

Is it possible to do all this with one request?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2016-05-08
@tupoi_nub

Delete all users with lastvisit NULL and create_time greater than 3 days ago?
Well, why is it so difficult?

delete from users where lastvisit IS NULL and create_time < now() - interval '3 day'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question