Solved

Simple SQL problem

Posted on 2014-03-25
1
127 Views
Last Modified: 2014-03-25
Hi all!

I have a mysql table with contacts.

In this table I have a field called id_city and city_name.

I have another table called states where I have id_state, state_name and, related to it, all the id_city that are in that state.

I would like to prepare a query that shows me all the contacts living in all the city in a state using simply the state name...

How can I achieve this?
0
Comment
Question by:ltpitt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
ltpitt earned 0 total points
ID: 39952775
I think I did it!
I just needed a subquery:

SELECT allthefieldsyouneed
FROM youtable
where id_city = (select id_city from states where state_name = 'yourstatename')

Thanks anyway :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need multiple Group By's 8 55
Can a Trigger trigger a Trigger? 4 47
transfer content to new site design 7 49
wordpress 4.7.4, theme 8 40
Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This video teaches users how to migrate an existing Wordpress website to a new domain.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question