query
What is it?
A query is a request to a database to retrieve, insert, update, or delete data. In web and mobile development queries are usually SQL statements such as SELECT, INSERT, UPDATE and DELETE that return a result set or an execution status. Important considerations include how parameters are passed (e.g. parameterized queries), performance (indexes, joins, LIMIT, pagination) and security risks like SQL injection. MySQL is a client-server database with richer concurrency features; SQLite is an embedded database commonly used on devices with different constraints and optimizations.
Practical example
Example: you build a mobile notes app that works offline using SQLite. To fetch the latest 20 notes for a user you use a parameterized query such as 'SELECT * FROM notes WHERE user_id = ? ORDER BY updated_at DESC LIMIT 20'. Using a parameter prevents SQL injection and lets you reuse the same query with different values. On a server-side API with MySQL you'd run similar queries but also create indexes on user_id and updated_at to speed things up, and you'd use prepared statements or an ORM to improve security and maintainability.
Test your knowledge
Which of the following methods is the most reliable way to prevent SQL injection when executing MySQL/SQLite queries?