Re: SQL Join challenge

From: Andreas Schmidt (a_j_schmidt_at_rocketmail.com)
Date: 10/29/03


Date: Wed, 29 Oct 2003 16:58:41 +0100


"Steven Helms" <steve@sh3inc.com> schrieb im Newsbeitrag
news:3f9eb6fb$1@newsgroups.borland.com...
> Sorry about that, bad cut and paste.
> Here is the current cut and paste without editing. Same syntax error
> (missing operator)
>
> qryJobData.SQL.Add('SELECT LOG.*, ');
> qryJobData.SQL.Add('Appraisers.FULLNAME AS AppraiserName, ');
> qryJobData.SQL.Add('AppraisalType.DESC AS AppraisalType, ');
> qryJobData.SQL.Add('ReportType.DESC AS ReportType ');
> qryJobData.SQL.Add('FROM Log ' );
> qryJobData.SQL.Add('INNER JOIN Appraisers ON Log.APPRAISER =
> Appraisers.APPRAISERINITIALS ');
> qryJobData.SQL.Add('INNER JOIN ApraisalType ON LOG.APPRAISAL_TYPE =
> AppraisalType.APPRAISAL_TYPE ');
> qryJobData.SQL.Add('INNER JOIN ReportType ON LOG.REPORT_TYPE =
> ReportType.REPORT_TYPE ');
> qryJobData.SQL.Add('WHERE LOG.APPRAISAL_NUMBER = '+
> IntToStr(SelectedRecord) );

Your Code is a little bit error phrone.
If you accidently call this code snipped twice
you will have two SELECTs in qryJobData.SQL.

qryJobData.SQL.Clear; // clear the old statement
qryJobData.SQL.Add('SELECT LOG.*, ');
qryJobData.SQL.Add(....

or as one-liner:
qryJobData.SQL.Text := 'SELECT LOG.*, ';
qryJobData.SQL.Add(....

This version is my favorite:

qryJobData.SQL.Text :=
  'SELECT LOG.*, '#13#10+
  'Appraisers.FULLNAME AS AppraiserName, '#13#10+
  'AppraisalType.DESC AS AppraisalType, '#13#10+
  ...

Andreas



Relevant Pages

  • Finding missing syntax element
    ... the place you were last editing. ... at end of line syntax error at ./nms2.pl line 433, ... about global symbols which I use sort of poorly. ... the script ran `Strict' would find all the same stuff to holler about. ...
    (perl.beginners)
  • Re: Enter MULTIPLE Items in a Query (e.g. [Name:] ??
    ... Also, you need to enter the list of names, separated by commas, and NO spaces. ... > board and not part of the criteria line that you suggested. ... > ...then editing for my specfics returns a syntax error. ...
    (microsoft.public.access.queries)
  • Re: Enter MULTIPLE Items in a Query (e.g. [Name:] ??
    ... ....then editing for my specfics gets a syntax error. ... My actual situation concerns Route numbers (I used the Name example to try to ...
    (microsoft.public.access.queries)
  • Re: SQL Join challenge
    ... Same syntax error ... qryJobData.SQL.Add('Appraisers.FULLNAME AS AppraiserName, '); ... qryJobData.SQL.Add('INNER JOIN ReportType ON LOG.REPORT_TYPE = ...
    (borland.public.delphi.database.ado)