Subject Re: Queries
From Mervyn Bick <invalid@invalid.invalid>
Date Fri, 22 May 2020 12:47:23 +0200
Newsgroups dbase.getting-started

On 22/05/2020 00:29, Khalid Al Awadhi wrote:
> Greetings
> I come from an old school if dBase 5 dos
> I’m still not so understanding the terms of the new ones
> I understand that we can create more than one query on a DBF file
> Is that same as opening more than one NDX files on one DBF?
> In other words are index files replaced with queries?
> My second help request is how to create a query using sql

One needs to learn how to use any tool properly, even something as
simple as a hammer, before trying to do any work with it.  dBASE 2019 is
a fairly complex tool and you need to spend the time learning how to use
it BEFORE you try creating programs, forms or reports for yourself.

The dBASE tutorial has been carefully structured so that working through
it will take you from the absolute basics to fairly complex concepts.

If you had worked through the tutorial you would not have needed to ask
the questions you have posted so far.  Unfortunately the tutorial can't
cover everything that dBASE can do but once you have mastered the basics
the newsgroups will help solve future problems.

Programming in OOP using objects and events to execute code is not
difficult but it is very different from the old dBASE for DOS way of
doing things.  The hard part is forgetting how something used to be done
and remembering the new way. The tutorial covers the new approach
required very well.

Using OOP, dBASE uses a query object to access a table instead of USE
<tablename> which dBASE for DOS used to open a table in a workarea.

Just as you could open the same table in several workareas, each with
it's own alias for easy reference, you can now create several instances
of a query object each of which gets its data from the same table.  Each
query has it's own name just as each workarea has it's own alias.

.NDX index files were for single indexes.  They still work but they have
to be kept up to date manually which is a nuisance.  Since dBASE IV
dBASE has used .MDX files which can contain up to 47 index tags which
are all kept up to date even if they are not in use when changes to the
key fields are made.

dBASE has never been able to apply more than one index to an open table
at a time.  A different index can, however, be applied to the table open
in each workarea or query where the same table has been opened multiple

dBASE query objects use localSQL (a subset of "proper" SQL) to fetch
data from a table.  The only SQL you need to know to start with is

    select * from tablename

This means select all the fields from the table and is the equivalent of
the old USE tablename command.

Once you have mastered the basic OOP concepts you can consider learning
basic SQL which will give you more control over the data fetched from
the table.  There are many SQL tutorials on the Internet.  The two I
found most helpful are
and  I used the second one as
a reference for years but I found the first one "easier" reading.  Be
aware though that localSQL as used in dBASE is limited but it is still
fairly powerful.  Not everything covered in the tutorials can be done in

You will find copies of the localSQL help file in .pdf and .chm format
in the binaries newsgroup.  Search for LocalSQL Help in the subject line.