Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with LEFT JOIN
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
00978845
Message ID:
00979373
Views:
18
I'm also playing with my first idea and can not make it work either:
SELECT MIN(Trans.ctrans_pk) AS ctrans_pk,;
  Trans.cclient_account_number, MIN(Patients.ddob) AS ddob,;
  MIN(Trans.tadmit_date) AS dos,;
  MIN(PADR(NVL(ALLTRIM(Names.cl_name)+", ","")+NVL(ALLTRIM(Names.cf_name)+" ","")+NVL(Names.cm_initial,""),50)) AS cpatient_name,;
  MIN(Product_lines.cproduct_line) AS cproduct_line,;
  MIN(Trans.cresolution_codes_fk) AS cresolution_codes_fk,;
  MIN(Trans_status_codes.cstatus_codes_fk) AS cstatus_codes_fk,;
  MIN(PADR(NVL(Phones.carea_code,"")+NVL(Phones.cexchange,"")+NVL(Phones.clast_four,""),10)) AS cphone;
 FROM ;
     mmviscollect!patients ;
    INNER JOIN mmviscollect!trans ;
   ON  Patients.cpatients_pk = Trans.cpatients_fk ;
    LEFT OUTER JOIN mmviscollect!phones ;
   ON  Patients.cpatients_pk = Phones.cpointer_fk ;
    INNER JOIN mmviscollect!trans_status_codes ;
   ON  Trans.ctrans_pk = Trans_status_codes.ctrans_fk ;
    INNER JOIN mmviscollect!product_lines ;
   ON  Product_lines.cproduct_lines_pk = Trans.cproduct_lines_fk ;
    INNER JOIN mmviscollect!names ;
   ON  Patients.cpatients_pk = Names.cpointer_fk;
 WHERE ( ( ( ( ( (  Trans.cclient_account_number LIKE ( ?vp_cClient_Account_Number );
   AND  Trans_status_codes.iactive_flag = ( 1 ) );
   AND  Names.cl_name LIKE ( ?vp_cLast ) );
   AND  Names.cf_name LIKE ( ?vp_cFirstName ) );
   AND  Names.cm_initial LIKE ( ?vp_cMiddle ) );
   AND  Patients.cssn LIKE ( ?vp_cSSN ) );
   AND  (  ( ?vp_cAreaCode ) == ( "" );
   OR  Phones.carea_code = ( ?vp_cAreaCode ) ) );
   AND  (  ( ?vp_cExchange_Four ) == ( "" );
   OR  ( Phones.cexchange+Phones.clast_four ) = ( ?vp_cExchange_Four ) );
 GROUP BY Trans.cclient_account_number
If I am searching by phone only, the search is very slow, because as it is written it doesn't use my indexes on cArea_Code or cExchange+cLast_Four

>>>Hi nadya,
>>>
>>>It does work with the view designer. However you'll have to omit the question mark. (so &cWhere) and be sure the cWhere variable does not exists. I'm not sure what you mean by "use this view as part of database" though. all views are part of a database....
>>>
>>>Walter,
>>>
>>Is it changed when you do requery() ?
>>
>>I have to try it...
>>
>>It doesn't allow me to do it. I open ViewSQL, remove my where condition and put &cWhere instead of the whole where clause. It produces an error and reverts back to original filter. What can I do?
>>
>>Thanks.
>
>Just set a public variable cWhere = ".t." before saving the view or make cWhere as a parameter to view (Char Type) but then You must change WHERE clause to &?cWhere
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform