[PHP-DB] Select Query Help...

2002-12-10 Thread Michael Knauf/Niles

select query question

OK, I have 3 tables

Products Table
  prodid
  fgnumber
  name
  description

Faqs Table
  faqid
  question
  answer

FaqsRelatedToProducts Table
  fpid
  fgnumber
  faqid

I want to select all the faq question and answer pairs that relate to an
fgnumber so I need to use both the Faqs table and the FaqsRelatedToProducts
table, how do I make that work?

Michael



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Select Query Help...

2002-12-10 Thread Ignatius Reilly
Try:

SELECT DISTINCT F.question, F.answer
FROM Faqs AS F, FaqsRelatedToProducts Table AS FP
WHERE F.faqid = FP.faqid

DTH?
Ignatius

- Original Message -
From: "Michael Knauf/Niles" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 10, 2002 8:53 PM
Subject: [PHP-DB] Select Query Help...


>
> select query question
>
> OK, I have 3 tables
>
> Products Table
>   prodid
>   fgnumber
>   name
>   description
>
> Faqs Table
>   faqid
>   question
>   answer
>
> FaqsRelatedToProducts Table
>   fpid
>   fgnumber
>   faqid
>
> I want to select all the faq question and answer pairs that relate to an
> fgnumber so I need to use both the Faqs table and the
FaqsRelatedToProducts
> table, how do I make that work?
>
> Michael
>
>
>
> --
> 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




RE: [PHP-DB] Select Query Help...

2002-12-11 Thread Hynek Semecký ME
This should work as well (newer syntax) ?:

SELECT  F.question, F.answer
FROMFaqsAS F
LEFT JOIN   FaqsRelatedToProducts   AS FP   ON F.faqid = FP.faqid
WHERE   fgnumber = '$yourfgnumber'


Use:
SELECT DISTINCT ...
when your FaqsRelatedToProducts table includes identical "fgnumber-faqid"
rows.


:)
Hynek



-Original Message-
From: Ignatius Reilly [mailto:[EMAIL PROTECTED]]
Sent: 10. prosince 2002 23:42
To: [EMAIL PROTECTED]; Michael Knauf/Niles
Subject: Re: [PHP-DB] Select Query Help...


Try:

SELECT DISTINCT F.question, F.answer
FROM Faqs AS F, FaqsRelatedToProducts Table AS FP
WHERE F.faqid = FP.faqid

DTH?
Ignatius

- Original Message -
From: "Michael Knauf/Niles" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 10, 2002 8:53 PM
Subject: [PHP-DB] Select Query Help...


>
> select query question
>
> OK, I have 3 tables
>
> Products Table
>   prodid
>   fgnumber
>   name
>   description
>
> Faqs Table
>   faqid
>   question
>   answer
>
> FaqsRelatedToProducts Table
>   fpid
>   fgnumber
>   faqid
>
> I want to select all the faq question and answer pairs that relate to an
> fgnumber so I need to use both the Faqs table and the
FaqsRelatedToProducts
> table, how do I make that work?
>
> Michael
>
>
>
> --
> 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