...

View Full Version : very hard mysql query



runeveryday
05-21-2011, 04:47 AM
table one structure {node}:


nid type title created

10 provider test one 1298107010
11 provider test two 1298107555
12 provider example one 1300524695
13 provider example two 1298081391
14 provider example three 1298082340
15 company example four 1298083519
16.... company example five 1298083559

table two structure {votingapi_vote}:


content_id value value_type

10 1 option
10 0 option
11 1 option
12 0 option
15 3 percent
15 2 percent
16..... 0 option
i want:

get 22 titles list


...
test one
test two
example one
example two
...
[

1, the value of nid is equals the value of content_id in table 2.

the title list queue order is:

1, first according to table 2 content_id descending the tile list(decending content_id using "For each content_id, the number of rows with value=1 minus the number of rows with value=0" )

2, because table2 maybe less than 22 records and has the same value when the number of rows with value=1 minus the number of rows with value=0. when emerge this condition. using the created field in table 1 to descending the tile



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum