473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

select data from mysql

250 100+
I have a table named as tb1 and have two fields ID and CITY. One city can have more than one id. I want to write a query to select ids from tb1 in one city.
Eg. if city1 has id1,id2,id3 then i want to dispay all three ids that is in city1.
i'm new to mysql and please someone help me..
Mar 26 '08 #1
2 1202
I have a table named as tb1 and have two fields ID and CITY. One city can have more than one id. I want to write a query to select ids from tb1 in one city.
Eg. if city1 has id1,id2,id3 then i want to dispay all three ids that is in city1.
i'm new to mysql and please someone help me..

select id,city from tb1
where city in (select city from city1)
Mar 26 '08 #2
amitpatel66
2,367 Expert 2GB
I have a table named as tb1 and have two fields ID and CITY. One city can have more than one id. I want to write a query to select ids from tb1 in one city.
Eg. if city1 has id1,id2,id3 then i want to dispay all three ids that is in city1.
i'm new to mysql and please someone help me..
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT id from tb1 WHERE city = 'city1';
  3.  
  4.  
Mar 26 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: phpfrizzle | last post by:
Hi there, I have a site with products on it. The site has a mysql backend. All products belong to certain series (table series). There can be up to 4 different products (table products)...
0
by: Tanamon | last post by:
Hello All, I am a MySQL newbie trying to write a query that selects file_name records possessing the highest numbered version for that unique file_name. I show sample data and two trial queries...
0
by: Verdon vaillancourt | last post by:
Hi :) I'm not even sure if I'm naming the question correctly. I hope I can ask/explain it clearly enough to get a hint ;) Essentially... 1) I have a table of portfolio 'pieces', each row of...
3
by: Hendry Taylor | last post by:
I have a problem where if I issue a select * from against a database it returns no data, but if I select column from it returns the data. Why would the * not be working as a wildcard?
17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
2
by: phpuser32423 | last post by:
Hi everyone Is it by any chance possible to use mysql and php to auto create the content for drop-down lists on forms by retrieving the values from a database? The reason i ask is that on a site...
2
by: PRS | last post by:
Why does 'SELECT * FROM countries' truncate characters and SELECT country FROM countries does not ? mysql> SELECT * FROM countries; +-------------+-----------+ | country | capital |...
1
by: JJ | last post by:
I need to do a SELECT query that joins four tables. The largest of the tables could eventually have over 1 million records. I need to do a SELECT that returns a maximum of 1000 records which will...
0
by: ZoombyWoof | last post by:
Hi. I have ran into a weird thing I just can't find any solution for. I have googled and searched but no luck. The problem is that when I select TIME values from MySQL from python, I get wrong...
12
by: Austin | last post by:
$lines = file("list.txt"); $l_count = count($lines); for($i = 0; $i < 3; $i++) { $var = $lines; } mysql_query("SELECT name FROM list WHERE name='$var'");
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.