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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:22:13+00:00 2026-05-13T07:22:13+00:00

I am making a website where users add the place where they have visited.

  • 0

I am making a website where users add the place where they have visited.

There is 4 main tables

users (user_id,name )
places (place_id,type_id,place_name, city_id)
user_place (user_id,place_id, date )
city(city_id,city_name)

Now I need to take with one query all the places which are type of 2 (where type=2) where the given users participate (user_id=43 lets say) with the name of the place, name of the city and the quantity of ALL OTHER users which are also participating in the same place…
Yesterday with one book about mysql I came to such thing

    SELECT *
    FROM `user_place` , `places`,(SELECT count(user_id) 
 from user_places
 WHERE user_place.place_id = places.place_id) as count
    WHERE user_place.place_id = places.place_id
    AND user_place.user_id =53

But its giving error:Unknown column ‘places.place_id’ in ‘where clause’
And still no Idea how can I also attach smartly the place name and city name to the result…
Please help if you can…

  • 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-13T07:22:13+00:00Added an answer on May 13, 2026 at 7:22 am
    SELECT p.place_id, p.place_name, c.city, placeCount.Cnt
    FROM places p
    INNER JOIN user_place up ON p.place_id = up.place_id
    INNER JOIN fa_user u ON up.user_id = u.id
    INNER JOIN city c ON p.city_id = c.id
    LEFT JOIN (
    
    SELECT place_id, COUNT( DISTINCT user_id ) Cnt
    FROM user_place
    WHERE user_id <>53
    GROUP BY place_id
    )placeCount ON p.place_id = placeCount.place_id
    WHERE up.user_id =53
    LIMIT 0 , 30
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

An email confirmation gets sent when my website users making a booking. I have
i'm making a website where users can input some BBcodes and my owan BBcode
I'm making a website that mail users when a movie or a pc game
I have a website that uses the AjaxControlToolkit. I'm making some parallel iPhone-friendly pages
I'm making a website using JSP and servlets and I have to now break
I am making a website where users can upload pictures and draw on them,
I have a file upload form on my website and would like to add
I am making a website gallery page, and in the meta tags I have
Sorry for the newbie question! I'm making a small website that allows users to
I want to create a website/webapp to aid users in making translations of foreign

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.