Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with SQL Query
Message
From
18/09/1999 19:31:05
 
 
To
18/09/1999 09:58:43
Antonio Gubaira
Ingenieria Y Sistemas
Valencia, Venezuela
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00266315
Message ID:
00266416
Views:
16
>Hi,
>
>I am using a Listbox to display the results of a query by means of a SQL statement. The statement is:
>
>SELECT a.fchvence,a.hora,a.descrip,b.nombre,b.represen,b.cliente,
>a.proyecto,a.reg FROM actividades AS a INNER JOIN proyectos AS b ON a.proyecto=b.proyecto INTO CURSOR curpendientes ORDER BY 1,2
>HAVING a.estatus=1 and a.usuario=glbusuario and (a.clase=mClase or
>IIF(mClase=4,.T.,.F.))
>
>FIRST:
> For the records in 'actividades' with a match in 'proyectos' the result is perfect and all items are listed accordingly; but when a record in 'actividades' does not have a match in 'proyectos', that item is repeated in the Listbox as many times as the total amount of records in 'proyectos'.
>
>Which is the reason for this behaviour and how can I fix this situation ?
>
>SECOND:
>If I declare a Public variable in the form that contains the Listbox object and use it as part of condition2 I get the following error message: "Column Not Found in SQL" The only way it works is declaring the same variable Public in the main program. Note that in both cases the variable is initialized in the Init method of the Listbox. In the case above the variable is 'mClase'.
>
>Why does this happen ?

First: use WHERE instead of HAVING. SQL itself looks Ok, but HAVING is not recommended to use for this construction (no GROUP), therefore WHERE might work better.
Second: don't use variables. Instead, create form custom property and use it appropriately: ....IIF(Thisform.mClase=4,.T.,.F.))...
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform