Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with SQL Syntax
Message
From
02/07/2002 01:46:04
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00674080
Message ID:
00674300
Views:
20
>>I used a JOIN-statement to make this work,
>> however it has the odd-behaviour that it only
>> shows the records which any of the users has
>> already accessed. So there has to be an entry
>> for a master record in the child table for the
>> user (which has never accessed the record) to
>> see the record.
>
>I believe you have the tables inverted in your SQL statement. You might need to either use a RIGHT OUTER JOIN or invert tables in your LEFT OUTER JOIN (e.g. SELECT * FROM master LEFT OUTER JOIN tableuser).

Oops, you caught me there. I've been trying so much that I messed it up. Okay, here's the clean syntax after executing this procedure.
 SELECT tblMaster.id, desc FROM tblMaster
 LEFT OUTER JOIN tblUser ON tblMaster.id = tblUser.id AND tblUser.user = 'JOH'
 WHERE tblMaster.installed == .T. AND
   NOT tblUser.notshown == .t.
 ORDER BY Desc
 INTO CURSOR crsGameTemp
Okay, after pasting this code here, I see where the error is. The clause 'NOT tblUser.notshown == .T.' may not be outside of the join statement. This messes it up. When I move that piece of code to the join like this:
 SELECT tblMaster.id, desc FROM tblMaster
 LEFT OUTER JOIN tblUser ON tblMaster.id = tblUser.id 
   AND tblUser.user = 'JOH' 
   AND NOT tblUser.notshown == .t.
 WHERE tblMaster.installed == .T. 
 ORDER BY Desc
 INTO CURSOR crsGameTemp
I always get all the results, and the filter on not showing the 'notshown' records doesn't work.

Johan
Previous
Reply
Map
View

Click here to load this message in the networking platform