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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:54:11+00:00 2026-06-12T12:54:11+00:00

I’m trying to JOIN two tables but it isn’t working properly. I have loc_id

  • 0

I’m trying to JOIN two tables but it isn’t working properly. I have loc_id in all tables and they all have a value of 1. My database is INNODB. loc_id is the Unique ID for a third table called b_locations. I had tried including this table on JOIN as well but I don’t really need it and that also gave me the same results. I’d like to be able to JOIN 3 or more tables for future proofing, but I need to get 2 working first obviously.

Is my approach of joining on a Unique ID of a table not included in the query a bad approach?

Here is my SQL:

SELECT d.view_id,
    d.gps_lat survey_lat,
    d.gps_lng survey_lng,
    d.thumbnail,
    c.sign_type,
    c.gps_lat object_lat,
    c.gps_lng object_lng
FROM `d_view_angles` AS d
JOIN c_survey_elements AS c
ON d.loc_id = c.loc_id
WHERE c.loc_id = '1'

Here is what I am getting (See bold text below desired results):

1   37.367156   -77.39987   ... FREESTANDING SIGN   37.367229   -77.399835
2   37.367305   -77.399801  ... FREESTANDING SIGN   37.367229   -77.399835
3   37.36739    -77.400022  ... FREESTANDING SIGN   37.367229   -77.399835
4   37.367619   -77.399897  ... FREESTANDING SIGN   37.367229   -77.399835
1   37.367156   -77.39987   ... DOWN LIGHTING       37.367408   -77.400077
2   37.367305   -77.399801  ... DOWN LIGHTING       37.367408   -77.400077
3   37.36739    -77.400022  ... DOWN LIGHTING       37.367408   -77.400077
4   37.367619   -77.399897  ... DOWN LIGHTING       37.367408   -77.400077
1   37.367156   -77.39987   ... DOWN LIGHTING       37.367635   -77.399944
2   37.367305   -77.399801  ... DOWN LIGHTING       37.367635   -77.399944
3   37.36739    -77.400022  ... DOWN LIGHTING       37.367635   -77.399944
4   37.367619   -77.399897  ... DOWN LIGHTING       37.367635   -77.399944

I have tried GROUP BY survey_lat, survey_lng but it takes the top 4 results which gives me the following (notice the repeating c.sign_type, c.gps_lat and c.gps_lng):

1   37.367156   -77.39987   ... FREESTANDING SIGN   37.367229   -77.399835
2   37.367305   -77.399801  ... FREESTANDING SIGN   37.367229   -77.399835
3   37.36739    -77.400022  ... FREESTANDING SIGN   37.367229   -77.399835
4   37.367619   -77.399897  ... FREESTANDING SIGN   37.367229   -77.399835

These are the results I should be getting:

1   37.367156   -77.39987   ... FREESTANDING SIGN   37.367229   -77.399835
2   37.367305   -77.399801  ... FREESTANDING SIGN   37.367229   -77.399835
3   37.36739    -77.400022  ... DOWN LIGHTING       37.367408   -77.400077
4   37.367619   -77.399897  ... DOWN LIGHTING       37.367635   -77.399944

I’m sure it is something stupid simple but I haven’t been able to track down the issue yet. My guess is my JOIN, but I have read numerous tutorials, been all over W3Schools, tried different JOINS (INNER JOIN, RIGHT JOIN, RIGHT OUTER JOIN, etc) and watched Youtube tutorials. If it is not in my SQL statement then recommendations on table formatting are welcome, if any other information is needed just let me know.


I have no control over the MYSQL version, this is run off a remote server, hosted by SurpassHosting (I do NOT recommend them).

MYSQL Server version: 5.0.95-community
Protocol version: 10
Running SQL query through PHPMyAdmin Version information: 3.4.10.1 and MSQL WorkBench 5.2.37 CE

  • 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-12T12:54:12+00:00Added an answer on June 12, 2026 at 12:54 pm

    It seems clear that for the same loc_id of 1 that there are 4 records in the left table (d_view_angles) and 3 records in the right table (c_survey_elements).

    This may mean that you need to use more than just loc_id to join on.

    Displaying the relevant contents of each table will make this clear.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.