Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need advice on SQL
Message
From
17/09/2006 17:12:37
 
 
To
17/09/2006 10:00:46
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01154440
Message ID:
01154507
Views:
4
>>
>>SELECT Program.Numero,Program.Active,Program.Title,Program.Notes_E,Program.Notes_F,Program.NoMaster,;
>> Master.FirstName,Master.LastName,MasterType.Title_E AS MasterType_E,MasterType.Title_F AS MasterType_F,Video.Url,Video.Numero AS PrimaryKey;
>> FROM Program;
>> INNER JOIN Master ON Program.NoMaster=Master.Numero;
>> INNER JOIN MasterType ON Master.NoMasterT=MasterType.Numero;
>> INNER JOIN Video ON Program.Numero=Video.NoProgram;
>> INNER JOIN InvoiceI ON Video.Numero=InvoiceI.NoVideo;
>> INNER JOIN Invoice ON InvoiceI.NoInvoice=Invoice.Numero;
>> WHERE Program.Active AND Invoice.AddUser=1;
>> AND Video.Numero=(SELECT MIN(Numero) FROM Video V WHERE V.NoProgram=Video.NoProgram);
>> ORDER BY Program.Title
>>
>
>Thanks, but there must be a syntax that is not shown because if I try my original SQL, it does return one record but it is not the first one from the program. When I try yours, it doesn't return any record.

try
SELECT Program.Numero,Program.Active,Program.Title,Program.Notes_E,Program.Notes_F,Program.NoMaster,;
 Master.FirstName,Master.LastName,MasterType.Title_E AS MasterType_E,MasterType.Title_F AS MasterType_F,Video.Url,Video.Numero AS PrimaryKey;
 FROM Program;
 INNER JOIN Master ON Program.NoMaster=Master.Numero;
 INNER JOIN MasterType ON Master.NoMasterT=MasterType.Numero;
 INNER JOIN Video ON Program.Numero=Video.NoProgram;
 INNER JOIN InvoiceI ON Video.Numero=InvoiceI.NoVideo;
 INNER JOIN Invoice ON InvoiceI.NoInvoice=Invoice.Numero;
 WHERE Program.Active AND Invoice.AddUser=1;
 AND Video.Numero=(SELECT MIN(Numero) FROM Video V WHERE V.NoProgram=Video.NoProgram AND V.Numero=InvoiceI.NoVideo);
 ORDER BY Program.Title
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform