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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:12:34+00:00 2026-05-27T15:12:34+00:00

I am trying to get information from 3 tables in my database. I am

  • 0

I am trying to get information from 3 tables in my database. I am trying to get 4 fields. ‘kioskid’, ‘kioskhours’, ‘videotime’, ‘sessiontime’. In order to do this, i am trying a join in a subquery. This is what I have so far:

SELECT k.kioskid, k.hours, v.time, s.time
FROM `nsixty_kiosks` as k
LEFT JOIN (SELECT time
FROM `nsixty_videos` 
ORDER BY videoid) as v
ON kioskid = k.kioskid LEFT JOIN
(SELECT kioskid, time
FROM `sessions` 
ORDER BY pingid desc LIMIT 1) as s ON s.kioskid = k.kioskid
WHERE hours is NOT NULL

When I run this query, it works but it shows every row instead of just showing the last row of each kiosk id. Which is meant to show based on the line 'ORDER BY pingid desc LIMIT 1'.

Any body have some ideas?

  • 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-05-27T15:12:35+00:00Added an answer on May 27, 2026 at 3:12 pm

    Instead of joining to s, you can use a correlated subquery:

    SELECT k.kioskid,
           k.hours,
           v.time,
           ( SELECT time
               FROM sessions
              WHERE sessions.kioskid = k.kioskid
              ORDER
                 BY pingid DESC
              LIMIT 1
           )
      FROM nsixty_kiosks AS k
      LEFT
      JOIN ( SELECT time
               FROM `nsixty_videos` 
              ORDER BY videoid
           ) AS v
        ON kioskid = k.kioskid
     WHERE hours IS NOT NULL
    ;
    

    N.B. I didn’t fix your LEFT JOIN (...) AS v, because I don’t understand what it’s trying to do, but it too is broken; the ON clause doesn’t refer to any of its columns, and there’s no point in having an ORDER BY in a subquery unless you also have a LIMIT or whatnot in there.

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

Sidebar

Related Questions

I'm trying to get information from a cookie into Alfresco Share. I have a
I am trying to use python's telnetlib module to get information from a remote
Hi I am trying to get information on an Oracle package directly from PHP
I am trying to get information on the version of Windows installed from WMI.
i have to get static information from one 'module' to another. I'm trying to
Using ASP.NET MVC when trying to get the information stored on my Session[objectName] from
Ok, so I am trying to extract the information from a cache.dat database sent
I am trying to get metadata from an sqlite database. The main purpose for
I'm having trouble seeing tables from one particular SQL Server 2008 database while trying
I am trying to display information from database. I have set $config['per_page'] to 2,

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.