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 7818407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:33:56+00:00 2026-06-02T06:33:56+00:00

I am struggling with some sql and could use some help. I am sure

  • 0

I am struggling with some sql and could use some help. I am sure it’s pretty novice stuff for a lot of people.

Here is an example:
I am trying to select all the pictures that are not in an album, when the albumid is supplied.

The tables

Picture table

    pictureid
    picturename

Album_Picture Association Table

    albumpictureid
    albumid
    pictureid

Album Table – I don’t think this table needs to be referenced in the SQL.

    albumid
    albumname

I am assigning pictures to an album, and want to just display the pictures that havent already been assigned.

Extra credit: What would be even better is if I could select all the pictures in the table and be able to know which ones are in the album already, instead of omitting them from the returned data.
Then I could still show the image and just not allow it to be assigned.

Hope that all makes sense.
Thank you for any help.

using MYSQL 5

  • 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-02T06:33:58+00:00Added an answer on June 2, 2026 at 6:33 am

    For your first question, this query will return you the pictures where there doesn’t have an association inside of your album_picture association table.

      SELECT 
        * 
      FROM 
        pictures 
      WHERE 
        pictureid NOT IN (SELECT pictureid FROM album_picture)
    

    A simple way of returning both is to add another column, performing two queries (one to give you the assigned pictures and one to give you the unassigned pictures), and getting the union of both.

      (SELECT pictures.*, 'n' AS `assigned` .... ) UNION (SELECT pictures.*, 'y' AS `assigned` ...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a python novice and am struggling with some concepts here - any help
I'm struggling with some SQL/php syntax issues here. I'm trying to write two functions.
I'm struggling on some coding and was hoping someone could help me out please,
I've been struggling for some time now to be able to use the built-in
Been struggling with this for quite some time so any help is appreciated. Spent
I'm struggling with PL/SQL functions. I'm trying to write a function which would take
I'm struggling with a homework assignment and am getting hung up on some SQL
I'm refactoring some older SQL, which is struggling after 4 years and 1.7m rows
I'm really struggling to wrap my head around some of this stuff. Let me
I'm struggling for some hours now with this problem: I'm trying to get my

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.