RE: [PHP] Re: SQL Query
| From: | Willie G | Date: | Sat, 15 Feb 2003 14:08:14 +0000 |
| Subject: | RE: [PHP] Re: SQL Query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-135663@lists.php.net to get a copy of this message | ||
Zydox,
Please define 'sub-interest'. I've looked at what Uttam gave you, and it
looks correct, assuming you want want it limited to the same user. If you
result should be 'all with Interest = X and Valid = Y", just remove the
userid from the second query.
SELECT
InterestsList.ID, InterestsList.SubID, InterestsList.Interest,
InterestsList.Valid
FROM InterestsIndex
INNER JOIN InterestList
ON InterestIndex.InterestID=InterestList.ID
WHERE
InterestList.SubID='3' AND
InterestList.Valid='1'
- Larry
-----Original Message-----
From: Zydox [mailto:Zydox@Hotmail.com]
Sent: Saturday, February 15, 2003 7:58 AM
To: php-general@lists.php.net
Subject: [PHP] Re: SQL Query
Those querys work... but they don't get all the Sub Interests...
"Uttam" <uttam@lml.co.in> wrote in message
news:97FB62E1E350D511B71F00A0C99D0CC30352D563@MSEXCHANGE...
> if i understand you correctly then this should give valid interests of a
> user:
>
> SELECT DISTINCT
> InterestsList.SubID
> FROM
> InterestsIndex INNER JOIN InterestList
> ON InterestIndex.InterestID=InterestList.ID
> WHERE
> InterestIndex.UserID='1' AND
> InterestList.Valid='1'
>
> and if the chosen interest is '3' then valid subinterests are:
>
> SELECT
> InterestsList.ID, InterestsList.SubID, InterestsList.Interest,
> InterestsList.Valid
> FROM
> InterestsIndex INNER JOIN InterestList
> ON InterestIndex.InterestID=InterestList.ID
> WHERE
> InterestIndex.UserID='1' AND
> InterestList.SubID='3' AND
> InterestList.Valid='1'
>
> regds,
> -----Original Message-----
> From: Zydox [mailto:Zydox@Hotmail.com]
> Sent: Saturday, February 15, 2003 09:48
> To: php-general@lists.php.net
> Subject: SQL Query
>
>
> I have a problem writing a query that can select a Interest for a specific
> user... There are tvo tables, IList and IIndex...
> IList contains this :
> ID SubID Interest Valid
> Edit Delete 1 0 Datorer 0
> Edit Delete 2 1 Spel 0
> Edit Delete 3 2 Strategi 0
> Edit Delete 4 3 Star Craft 1
> Edit Delete 5 3 Star Wars: Gallactic Battelinggrounds 1
> Edit Delete 6 2 Shoot-Em-Up 0
> Edit Delete 7 6 Half-Life 0
> Edit Delete 8 7 Team Fortress 1
> Edit Delete 9 7 Counter-Strike 1
>
>
> And IIndex contains a UserID And InterestID... this query :
> "SELECT DISTINCTROW InterestsList.ID, InterestsList.SubID,
> InterestsList.Interest, InterestsList.Valid FROM InterestsList AS II RIGHT
> JOIN InterestsList ON InterestsList.ID=II.SubID LEFT JOIN InterestsIndex
ON
> InterestsList.ID=InterestsIndex.InterestID AND InterestsIndex.UserID='1'"
>
> Selects all rows from IList... even if there Is'nt any instans in IIndex..
.
> this thougt is that a User can choose a "Valid" Interest and then the
query
> should select all SubInterests... anyone know how to do that ?
>
> // Regards Zydox
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php