Category: 

What is Query by Example?

Article Details
  • Written By: Derek Schauland
  • Edited By: O. Wallace
  • Last Modified Date: 25 November 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
The Argentinian resort town of EpecuĂ©n was submerged by flooding for years; it is now populated by one elderly man.  more...

December 5 ,  1933 :  Prohibition ended in the US.  more...

Query by example (QBE) is a query language for relational databases similar to Structured Query Language (SQL). The "by example" portion of this data gathering language allows the person or application looking to retrieve data from the relational database to complete the information that they know about the data they are looking for. The Query by example method might include a form that the user would complete to generate a SQL query that the database understands.

Suppose for example that there existed a database full of employees in an organization and this information was made available to the employees in case they needed to communicate with other employees. The database storing the information understands commands like select fname from employees where lname = 'smith', however many people do not understand this type of syntax. Query by example can help with this. The following statement:

select fname, lname, extension from employees where lname ='smith'

tells the database to look through the employees table of information and display all of the first names (fname), last names, (lname), and phone extensions (extension) where the last name field contains the value smith. Using a QBE style query, the user looking for this information could provide the information that they know, last name = 'smith', and see the information related to that last name. This allows the employee to give an example of what they are looking for and see the results returned.

Ad

The query sent to the database in the above example looks just like the SQL statement shown above, even though the person performing the lookup told the database only that the last name was Smith and then which items he or she needed to know, the first name, last name, extension. Since most query by example use involves a form or application for data entry, the table employees could be hard coded into the system so the users do not need to worry about that.

Another similar example is the recipient lookup used by Microsoft Outlook Web Access®. When someone clicks the To field header, another form opens up allowing that person to complete the items they know about and click the find button, all records matching the specified example will be returned and the employee can click the correct information to use it in an email message.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email