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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:05:02+00:00 2026-06-02T12:05:02+00:00

I have a query that on the left join part should either return data

  • 0

I have a query that on the left join part should either return data or null. But even if there is existing records its not returning any data. The twist to the left join portion is that I would like to only retrieve one record if it exist. Thanks for any help.

select a.*,p.thumbnailphotopath as AlbumPicture 
from (select * from album_access) ac
inner join (select * from albums) a on a.ID = ac.AlbumID
left join (
    select * from photos 
    where IsProcessed = 1 order by DateUploaded desc limit 1
) p 
on a.ID = p.AlbumID #should return one if exist.
where ac.AccessUserID = '35e44a8e-643a-4c4f-8a46-59911a1e7c53' 
  and ac.FullControl = 1 and a.Private = 1
  • 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-02T12:05:04+00:00Added an answer on June 2, 2026 at 12:05 pm

    First you can just join on a table name and don’t need to join on a whole SELECT * FROM statement.

    Second, you should try not to use SELECT * and instead SELECT the columns you want.

    But I think the problem with your LEFT JOIN is that you’re joining on a sub-query that will only return one result, which will be the entry in photos that was last uploaded irrespective of which albumID it belongs to. If you want the entry in photos with the last uploaded date for each row, try something like this

    SELECT a.*,p.thumbnailphotopath AS AlbumPicture 
    FROM album_access ac
    INNER JOIN albums a ON a.ID = ac.AlbumID
    LEFT JOIN (
        SELECT albumID,MAX(DateUploaded) FROM photos 
        WHERE IsProcessed = 1 GROUP BY albumID
    ) p ON a.ID = p.AlbumID #should return one if exist.
    WHERE ac.AccessUserID = '35e44a8e-643a-4c4f-8a46-59911a1e7c53' 
      AND ac.FullControl = 1 
      AND a.Private = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a query that uses a left join. For reasons I don't
I have a query that I know can be done using a subselect, but
I have a query that updates one record, and only one record. Is there
I have this Query: SELECT p.ProductName, dt.MaxTimeStamp, p.Responsible FROM Product p LEFT JOIN (SELECT
I have a L2S query with several joins that should returns 11 records in
I have an array that's made up of data returned by a SQL query:
I have the following sql query SELECT * FROM jos_jcalpro_events AS e LEFT JOIN
I am using in C# MYsql .I have query that works if I run
I have a query that looks like SELECT P.Column1, P.Column2, P.Column3, ... ( SELECT
I have a query that looks a bit like this: SELECT weekEnd, MAX(timeMonday) FROM

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.