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

  • Home
  • SEARCH
  • 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 316905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:25:36+00:00 2026-05-12T08:25:36+00:00

Sorry for the horrible title, not sure how to explain this. I have a

  • 0

Sorry for the horrible title, not sure how to explain this. I have a query that looks like this:

SELECT `name`, `latitude`, `longitude`, `indoor`, `address`,
    `phone`, `email`, `website`, `closed`
FROM rocks INNER JOIN 
    (SELECT DISTINCT id FROM rock_types WHERE type="DWS" or type="Top rope")
    AS types ON rocks.id=types.id
WHERE (latitude>-180 AND latitude<180) AND (longitude>-180 AND longitude<180)

In addition to what I’m getting right now, I’d like to get the list of types associated with each id. How can I do this? Thanks

  • 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-12T08:25:36+00:00Added an answer on May 12, 2026 at 8:25 am

    Here is my take using traditional join syntax:

    SELECT rocks.name,
           rocks.latitude,
           rocks.longitude,
           rocks.indoor,
           rocks.address,
           rocks.phone,
           rocks.email,
           rocks.website,
           rocks.closed,
           rock_types.type
    
    FROM   rocks,
           rock_types
    
    WHERE  rocks.latitude  > -180                 AND
           rocks.latitude  < 180                  AND
           rocks.longitude > -180                 AND
           rocks.longitude < 180                  AND
           rocks.type_id   = rocks_types.id       AND
           rock_types.type IN ('DWS', 'Top rope')
    

    The rocks.id = rocks_types.id does the link between both tables.

    Here is how you can write the same query using INNER JOIN (both leads to the same result)

    SELECT rocks.name,
           rocks.latitude,
           rocks.longitude,
           rocks.indoor,
           rocks.address,
           rocks.phone,
           rocks.email,
           rocks.website,
           rocks.closed,
           rock_types.type
    
    FROM   rocks
           INNER JOIN rocks_types ON rocks.type_id = rocks_types.id
    
    WHERE  rocks.latitude  > -180                 AND
           rocks.latitude  < 180                  AND
           rocks.longitude > -180                 AND
           rocks.longitude < 180                  AND
           rock_types.type IN ('DWS', 'Top rope')
    

    EDIT: Based on your comment, the following will give you a comma separated list of types:

    SELECT rocks.name,
           rocks.latitude,
           rocks.longitude,
           rocks.indoor,
           rocks.address,
           rocks.phone,
           rocks.email,
           rocks.website,
           rocks.closed,
           (SELECT    GROUP_CONCAT(DISTINCT rock_types.type SEPARATOR ',')
            FROM      rock_types
            WHERE     rock_types.id = rocks.id                AND
                      rock_types.type IN ('DWS', 'Top rope')
            GROUP BY  rock_types.id
           ) AS type
    
    FROM   rocks
    
    WHERE  rocks.latitude  > -180    AND
           rocks.latitude  < 180     AND
           rocks.longitude > -180    AND
           rocks.longitude < 180
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I remade this post because my title choice was horrible, sorry about that. My
Horrible title of this question, I know. Sorry. I have four divs similar to
Sorry but I am not sure how to ask this question but I am
Sorry if this has been answered somewhere; I'm not quite sure how to phrase
That's a horrible title, sorry. Here's the scenario: WCF Service uses LINQ to get
Sorry my title is not great, this is my first real punt at moving
I'm sorry for the horrible title. Essentially, I have a containing div which contains
Sorry for constantly re-editing my question but looks like this is the only way
(Sorry for the not-so-good-title, I'm not sure how my problem can be solved, thus
Sorry for the bad title - I simply do not know what to call

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.