PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > Confused on Query's
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Confused on Query's

Réponse
 
LinkBack Outils de la discussion
Vieux 22/08/2007, 22h05   #1
Brian E Boothe
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Confused on Query's

lets say u have a table called Parts and another called Projects ,,,
how can u associate the Parts Table with the Projects table so lets say
u wanna add a Specific Part to a project maybe even add three parts
from the parts table and associate it with a specific project ???

so maybe u would have projectid = partsid ?

so your project id lets say would be 1222007BB but u wanna add 7
parts associated with that Projectid

hmm maybe whatever partnumber u add would be associated with the
projectid ???

such as Partnum = projectid ?? with a left join ?

can someone Give me an example of how i would do this ? thanks
alot


i wanna run a query and see the parts associated with each project !
thats my ultimate goal ,,




  Réponse avec citation
Vieux 23/08/2007, 01h18   #2
Brent Baisley
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Confused on Query's

I assume each part can be associated with multiple projects, which is
a many to many relation. In that case you need to create a "join"
table that holds the relation. Table like that are typically just 2
fields, one for the project id and one for the part id. You may want
to add other fields like a timestamp so you know when the part was
added to the project.

Your query on the three tables (projects, projparts, parts) would
look something like this:
SELECT projects.*, parts.* FROM projects
JOIN projparts ON projects.projectid=projparts.projectid
JOIN parts ON projparts.partsid=parts.partsid
WHERE projects.projectid="1222007BB"

You would change those to left joins if you are not sure whether a
project has any parts. If there are no parts, that query would not
return anything.

On Aug 22, 2007, at 5:05 PM, Brian E Boothe wrote:

> lets say u have a table called Parts and another called
> Projects ,,, how can u associate the Parts Table with the Projects
> table so lets say u wanna add a Specific Part to a project maybe
> even add three parts from the parts table and associate it with a
> specific project ???
>
> so maybe u would have projectid = partsid ?
>
> so your project id lets say would be 1222007BB but u wanna add 7
> parts associated with that Projectid
>
> hmm maybe whatever partnumber u add would be associated with the
> projectid ???
>
> such as Partnum = projectid ?? with a left join ?
>
> can someone Give me an example of how i would do this ?
> thanks alot
>
>
> i wanna run a query and see the parts associated with each
> project ! thats my ultimate goal ,,
>
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?
> unsub=brenttech@gmail.com
>


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 20h31.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,61710 seconds with 10 queries