SQL
Implement Basic Full-Text Search with LIKE
Perform simple keyword-based searches across text fields in your database using the SQL LIKE operator and wildcards for flexible matching.
SELECT id, title, content
FROM articles
WHERE title ILIKE '%web development%'
OR content ILIKE '%web development%'
ORDER BY created_at DESC;
How it works: This snippet demonstrates basic search functionality using the `ILIKE` operator (or `LIKE` for case-sensitive search) and the `%` wildcard. It finds articles where 'web development' appears in either the title or content, ordered by creation date. `ILIKE` is PostgreSQL-specific for case-insensitive matching; use `LOWER(column) LIKE LOWER('%keyword%')` for broader database compatibility.