473,405 Members | 2,310 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,405 software developers and data experts.

Mysql query:Select Field value

Hellow

i am facing a problem in mysql query plesae solve it.

I have a table Team_master with two field

Expand|Select|Wrap|Line Numbers
  1. 1. team_id
  2. 2. team_name 
  3.  
And another table league_team with three field
Expand|Select|Wrap|Line Numbers
  1. 1.id
  2. 2.team_id
  3. 3.league_id
  4.  
in first team team_master data is
Expand|Select|Wrap|Line Numbers
  1. 1   Boston
  2. 2   Monaco
  3. 3   manchaster
  4. 4   Others
  5.  
second table league_master has
Expand|Select|Wrap|Line Numbers
  1. id  team_id  leage_id
  2. 1   2        1
  3. 2   3        1
  4. 3   1        2
  5. 4   2        2
  6.  

My problem is when i am select league id =3 or 2 the found the team name correspondence of league.So any one can tell me how found the team_name if i am select any league ina single query.

when i am select the league id =2 them found the team_id so how will i found the name of team in a single row

Thanks,
Sandeep
Jun 2 '07 #1
2 2944
Atli
5,058 Expert 4TB
Ok.

If I'm understanding correctly, you need to find every team that matches a league_id?

To do this you can JOIN the tables. This can be done like this
Expand|Select|Wrap|Line Numbers
  1. SELECT team.team_name FROM teamTbl AS team
  2. INNER JOIN team_leagueTbl AS league 
  3.   ON league.team_id = team.team_id
  4. WHERE legue.league_id = 2;
  5.  
P.S.
I don't have the means to test the query right now but I will as soon as I can.
Jun 2 '07 #2
Lots of Thanks,

This query is work perfectlly....

Bye...




Ok.

If I'm understanding correctly, you need to find every team that matches a league_id?

To do this you can JOIN the tables. This can be done like this
Expand|Select|Wrap|Line Numbers
  1. SELECT team.team_name FROM teamTbl AS team
  2. INNER JOIN team_leagueTbl AS league 
  3.   ON league.team_id = team.team_id
  4. WHERE legue.league_id = 2;
  5.  
P.S.
I don't have the means to test the query right now but I will as soon as I can.
Jun 8 '07 #3

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

Similar topics

3
by: joemyre | last post by:
Hi everyone, What I'm trying to do is take php variables i got from user input, and pass them as the MySQL query terms. $query = "select * from ident where ".$searchtype1."=".$searchterm1."";...
2
by: JDJones | last post by:
Using PHP and MySQL. Trying to put a list of categories into a drop down select option of a form like: <form name="form" action="<? print $_SERVER?>" method="get"> <select name="subject">...
7
by: YoBro | last post by:
Hi, I am stuck and cannot think my way out of this small problem. I am coding in PHP but trying to write a MySql query. I have db that stores vehicles. I am trying to SELECT vehicles where...
2
by: Bill | last post by:
Question: For a table like this: Date | Description | Amount | Balance 9/25/04 | payment on acct | 25.00 | 0.00 10/1/04 | delivery | 54.25 | 54.25 11/5/04 | payment on...
11
by: pmarisole | last post by:
I am trying to use the vbscript "split" function on a multi-select field. I am trying to do a mass update of several records at a time. I am getting an error and I'm not sure what to do. Here is...
2
by: hph | last post by:
Please be gentle; I am a relative newbie for php/MySQL, and most of what I am doing is based on being self-taught using someone else's well-written code, and my own googling the answers to my...
6
by: alex.kemsley | last post by:
Hi guys, I have the following sql statemant to search a mysql database that gets if values from a form with combo box's in. SELECT * FROM hottubs, manufacturers WHERE manufacturers.manid =...
2
by: Brave | last post by:
I'm hoping someone can help me with a small issue. I have an asp page that displays informaton from an Access database. I want to create a form that allows users to display only data that...
0
by: Kangana | last post by:
I've created one table, which displays image and its corresponding design ID. This table is surrounded by FORM tag in order to pass hidden value (i.e, design ID). I want to use this design ID in...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.