Ok
Lets say for simplicity sake that I have 3 tables:
table one: contact
id
choice
table two: cust
id
first
last
title
company
table three: industry
id
industry
industry_other
So --- for example in table contact I may have:
id -> 1
choice -> choice#1
id ->1
choice ->choice#6
in table cust I may have
id -> 1
first -> John
last -> Doe
title -> pres
company -> ibm
in table industry I may have
id - > 1
industry -> computers
industry_other -> null
So --- I guess I need to run a join query or 3 queries. I need to display as such:
id name industry contact
1 John Doe computers choice#1,choice#6
As you can see, I will need to display more than one record for a given id from the
contact table.
Does this make more sense? I'm not sure how to do the query and display the result...
Any guidance is greatly appreciated...I'll name my first born after you ! Or my next
dog :)
mignon
>>> "Ricardo Lopes" <[EMAIL PROTECTED]> 03/26/04 10:54AM >>>
i dont understand this part:
"What's the smartest way to do the query ? I have 5 different tables I need
to query. I guess I can get the data I want by selecting all from the 5
tables then parsing"
Send your tables structure.
----- Original Message -----
From: "Mignon Hunter" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 26, 2004 3:07 PM
Subject: Re: [PHP-DB] Stumped with proper query & display
Can someone please help me or direct me to some scripts that might get me
unstuck, as I've not done this kind of query before.
To simplify:
Table 1
id 1
Name John Doe
company IBM
Table 2
id 1
choice choice #1
id 1
choice choice #2
So I have 2 records in table 2 that I need to tie in with id # 1 in table 1.
What's the smartest way to do the query ? I have 5 different tables I need
to query. I guess I can get the data I want by selecting all from the 5
tables then parsing through like:
while ($row = mysql_fetch_assoc($res)) {
foreach Table1.id {
if Table1.id == Table2.id{
echo <tr>
}}}
I could probably manage if I do 5 different queries with 5 different results
sets, but that is obviously inelegant and would create more overhead
I need to display as:
John Doe IBM Choice #1, Choice #2
Am I even close ? Need some help with the logic...
Thx for any guidance
mignon
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php