Subject Re: SQL Statement
From Robin Rickard <rob@no.spam.calculation.com.au>
Date Wed, 18 Jul 2018 02:10:00 -0400
Newsgroups dbase.getting-started

Thanks for the reply Ken.
I have just upgrade to 12 and got another copy of your book.
I will spend some quite time reading.
Regards Rob


Ken Mayer Wrote:

> On 7/17/2018 7:53 PM, Robin Rickard wrote:
> > Hi All
> > what is the best way of getting a SQL statement to only show records that are contained in a field.
> > example: i have a field for staffareas. in this there might be ADH or ABD etc.
> > A is an area that they work in, but they may also work in E, F etc
> > Using the "$" in non sql i used to go ... for mstaff $ staffareas
> > "Select * from staff.dbf where mstaff $ staffarea"  does not work.
> > Can somebody please guide me right direction.
>
> SQL does not understand the dBASE use of the dollar sign. It's a
> completely different language. (This is covered, by the way, in Volume 1
> of The dBASE Book ... there's a chapter that discusses doing things in
> SQL that you are used to doing in dBL)
>
>     "select * from staff where mstaff like '%" + staffarea + "%'"
>
> The nested quotes are necessary. If there are apostrophes in the data,
> reverse these -- change the double-quotes (") to single-quotes (') (and
> vice versa).
>
> The percent signs are wildcards -- putting one on either side of the
> contents of the variable staffarea means that value in that variable can
> have anything on either side of it ...
>
> Ken
>
>
> --
> *Ken Mayer*
> Ken's dBASE Page: http://www.goldenstag.net/dbase
> The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
> dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
> dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm