We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.
Software

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

What is Query by Example?

By Derek Schauland
Updated: May 17, 2024
Views: 11,192
Share

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.

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.

Share
WiseGeek is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.

Editors' Picks

Discussion Comments
Share
https://www.wisegeek.net/what-is-query-by-example.htm
Copy this link
WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.

WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.