MySQL Forums
Forum List  »  Optimizer & Parser

Re: Problem with LEF OUTER JOIN
Posted by: wdeveloper
Date: March 24, 2006 02:01PM

Just take this example of my situation:

tblCat
- ID
- Name
- Desc

tblCatDet
- ID
- CatID
- Color

Now tblCat has the following data:
1 Test Testdesc
2 Test Testdesc
3 Test Testdesc

tblCatDet has the following data:
1 1 clr
2 1 clr
3 3 clr


Now the query :

select * from tblCat C LEFT OUTER JOIN tblCatDet D ON C.ID=D.CatID WHERE D.color='2'

For the exact tble structure and query look at this:
tblthreads:
ID,
AuthorID,
Email,
Subject,
Body,
CreateDate,
LastUpdated,
TotalUpdates,
IsDeleted

tblthreadvisitsbyusers:
ID,
Thread,
UserID,
LastVisit

tblusers
ID,
Name


SELECT DISTINCT T.ID FROM tblthreads T LEFT OUTER JOIN tblthreadvisitsbyuser V ON T.ID=V.Thread WHERE (TIME_TO_SEC(TimeDiff(LastVisit,Createdate))<0 OR TIME_TO_SEC(TimeDiff(LastVisit,Createdate)) IS NULL) AND V.UserID=1
UNION ALL
SELECT DISTINCT R.ThreadID FROM tblthreadreplies R LEFT OUTER JOIN tblthreadvisitsbyuser V ON R.ThreadID=V.Thread WHERE (TIME_TO_SEC(TimeDiff(LastVisit,Date))<0 OR TIME_TO_SEC(TimeDiff(LastVisit,Date)) IS NULL) AND V.UserID=1

Thanks for all the help till now, hope this makes the problem more clear and we can have a solution soon. Or else may be I am trying to achieve somethg wrong.

Sandy

Options: ReplyQuote


Subject
Views
Written By
Posted
3247
March 19, 2006 04:01PM
1845
March 19, 2006 05:48PM
2447
March 20, 2006 04:04AM
2229
March 20, 2006 10:31AM
2023
March 20, 2006 03:02PM
1872
March 20, 2006 03:34PM
1946
March 21, 2006 06:35PM
1933
March 22, 2006 05:10PM
1974
March 22, 2006 07:06PM
Re: Problem with LEF OUTER JOIN
2108
March 24, 2006 02:01PM
2158
March 26, 2006 08:05PM
2146
March 26, 2006 11:40PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.