thanks for dedicating time.
I have two tables for a kind of social network, table A for contents and table B for likes:
TABLE A:
CREATE TABLE `A` (
`id` int(10) unsigned NOT NULL,
`id_user` int(10) unsigned NOT NULL,
`title` varchar(255) DEFAULT NULL,
`path` text,
`ext` varchar(15) DEFAULT NULL,
`image_type` varchar(100) DEFAULT NULL,
`link_url` text,
`creation_date` datetime DEFAULT NULL,
`size` float DEFAULT NULL,
`type` int(10) unsigned DEFAULT NULL,
`number_share` int(10) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `A`
ADD PRIMARY KEY (`id`), ADD KEY `id_user` (`id_user`);
And TABLE B:
CREATE TABLE B (
`id_b` int(10) unsigned NOT NULL,
`id_user` int(10) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `B`
ADD PRIMARY KEY (`id_b`,`id_user`), ADD KEY `id_user` (`id_user`);
I'd like to retrieve from mysql records with this order:
1st most popular
1st most recent
2nd most popular
2nd most recent
.....
Can anyone tell me how to combine this by mysql (if possibile) or something easy to use in php wich is not 2 different queries?
EDIT 1:
If i have this situation:
results from first select (popular): id 3 5 12 4 65 2
and
results from second select (recent):
id
100
121
3
i will go to print my elements width id:
id
3
100
5
121
12
i want that id=3 from the second query is not considered because already posted
Thanks!