I have a search box for each status of an item!
When I search, is this the right way to do it?
SELECT *
FROM (`site_pages`)
WHERE `title` LIKE '%php%'
OR `content` LIKE '%php%'
HAVING `status` != 'deleted'
AND `status` != 'concept'
When no search is committed I just use
... WHERE'status' != 'deleted' AND 'status' != 'concept'
A few possibilities for improvement:
There is no reason to use having, you should simply append additional where conditions.
You could create a statuses table, assigning numeric representations for the deleted/concept values, allowing you to easily change the name of a status add/enumerate all existing statuses. This reduces the overhead of storing many redundant text fields, and drastically improves the speed of comparisons against the status field, numeric comparisons being far faster than string comparisons.
You also might want to make the "deleted" status into a column on each record. As it stands, a record can be a concept, or delete, but not a deleted concept. What if you want to undelete a record? You've lost its pre-deletion status. This is how non-destructive deletion of records is typically done; either by activating a deleted bit, or deactivating an active bit.
Otherwise it looks like pretty standard SQL.