Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8842399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:56:54+00:00 2026-06-14T10:56:54+00:00

I need a SQL Query that shows me all polls a user (uid) has

  • 0

I need a SQL Query that shows me all polls a user (uid) has not voted yet.

Example:

  • There are pid 1, 2 and 3
  • uid 1 voted on poll 1 and 3

So I need the query that shows me the pid 2 he didnt vote yet.

This are the 2 tables:

CREATE TABLE IF NOT EXISTS `poll` (
`pid` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(200) NOT NULL,
`description` text NOT NULL,
`deadline` datetime NOT NULL,
PRIMARY KEY (`pid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;


CREATE TABLE IF NOT EXISTS `votes` (
`vid` int(11) NOT NULL AUTO_INCREMENT,
`pid` int(11) NOT NULL,
`uid` varchar(20) NOT NULL,
`tid` int(11) NOT NULL,
`votes` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`vid`),
KEY `pcid` (`pid`,`uid`),
KEY `uid` (`uid`),
KEY `tid` (`tid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;

//edit this should make it more clear

Constraints for table votes

ALTER TABLE `votes`
ADD CONSTRAINT `votes_ibfk_3` FOREIGN KEY (`pid`) REFERENCES `poll` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `votes_ibfk_4` FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `votes_ibfk_5` FOREIGN KEY (`tid`) REFERENCES `teams` (`tid`) ON DELETE CASCADE ON UPDATE CASCADE;

Can smbdy please help me. I guess it is a join with a WHERE and NOT LIKE but I just dont get it.

Merci!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:56:55+00:00Added an answer on June 14, 2026 at 10:56 am

    okay so this is my first answer. There might me more possibilities, but this should work.

    SELECT * FROM Poll WHERE pid NOT IN (SELECT pid FROM votes WHERE uid = 1);
    

    I’m not 100% sure this will work as I don’t know the database type from which you’re trying to retrieve your data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, the question says it all. I need a PL\SQL query that returns a
I need to be able to have an SQL query that searches my database
I currently have a SQL query that returns a number of fields. I need
Using Microsoft SQL server 2008 I have a query that is in need of
I need a Java function that returns the results of a SQL SELECT query
I need a SQL query to make all data in a column UPPER CASE?
I need an sql query to give me the following: All the values in
I need some help with SQL Query. I am trying to select all records
I work on AI chat bot. I need sql query to select a single
I need execute an SQL query in ORACLE it takes a certain amount of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.