Jump to content

Mysql Query > Mysql standart version


Sld

Recommended Posts

Hi there dwd\'s

 

(SELECT poll.id,topico,count(*) as votos,unix_timestamp(inicio) as i, unix_timestamp(fim) as f 

FROM poll_votes,poll 

WHERE poll_votes.pollid = poll.id and \'$datactual\'>inicio and \'$datactual\'>fim 

GROUP BY poll_votes.pollid)

UNION

(SELECT poll.id,topico,0,unix_timestamp(inicio) as i, unix_timestamp(fim) as f 

FROM poll 

WHERE \'$datactual\'>inicio and \'$datactual\'>fim and id 

NOT IN 

(SELECT poll.id 

FROM poll,poll_votes 

WHERE poll_votes.pollid=poll.id and \'$datactual\'>inicio and \'$datactual\'>fim))

LIMIT $pagstart, $max

 

I\'ve got this query and it works fine, in a beta version of mysql in standart nop since it doesnt support NOT IN syntax, can anyone helpme with this? Any other ideias?

 

Tks in advance

Link to comment
Share on other sites

greetings. i could be wrong, but i do not think not in is the problem. i think the issue is that within not in is a subquery, which the standard versions of mysql do not support. you could run that query separate and loop its results to construct the not in syntax. let me know what you find...

 

i have removed your other post--please do not double post in the forums. thanks...

Link to comment
Share on other sites

SELECT poll.id,topico,count(*) as votos,unix_timestamp(inicio) as i, unix_timestamp(fim) as f  

FROM poll_votes,poll  

WHERE poll_votes.pollid = poll.id and \'$datactual\'>inicio and \'$datactual\'>fim  

GROUP BY poll_votes.pollid)  

UNION  

(SELECT poll.id,topico,0,unix_timestamp(inicio) as i, unix_timestamp(fim) as f  

FROM poll  

WHERE \'$datactual\'>inicio and \'$datactual\'>fim and id  

NOT IN  

(SELECT poll.id  

FROM poll,poll_votes  

WHERE poll_votes.pollid=poll.id and \'$datactual\'>inicio and \'$datactual\'>fim)  

LIMIT $pagstart, $max

 

run the query in bold separately. create an array from this result and use the implode function to concat the id\'s; add this into the query; run the query, eg:

 

$poll_ids = // list of polls ids from first query, separated by commas

 

$other_query =

 

SELECT poll.id,topico,count(*) as votos,unix_timestamp(inicio) as i, unix_timestamp(fim) as f  

FROM poll_votes,poll  

WHERE poll_votes.pollid = poll.id and \'$datactual\'>inicio and \'$datactual\'>fim  

GROUP BY poll_votes.pollid)  

UNION  

(SELECT poll.id,topico,0,unix_timestamp(inicio) as i, unix_timestamp(fim) as f  

FROM poll  

WHERE \'$datactual\'>inicio and \'$datactual\'>fim and id  

NOT IN  

($poll_ids)  

LIMIT $pagstart, $max

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.