?
Solved

Simple SQL problem

Posted on 2014-03-25
1
Medium Priority
?
129 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

762 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