PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table products ( id int primary key, name varchar(255) ); insert into products values (1, 'Prod 1'), (2, 'Prod 2'); create table prod_views ( prod_id int references products(id), viewed_at datetime, index (prod_id) ); insert into prod_views values (1, now()), (1, now()); select id, coalesce(count(prod_id), 0) views_count from products left join prod_views on id = prod_id where viewed_at is null or viewed_at > date_sub(current_date, interval 1 week) group by id order by views_count desc limit 5
Copy Clear
Copy Format Clear
<?php $json_text = 'a:1:{s:7:"company";s:14:"d1a267810725d2";}'; $details = implode(array_keys(unserialize($json_text))); echo $details;
Show:  
Copy Clear