In terms of performance, what's better between select all rows from a table and then filter the results with PHP, or filter the query directly using WHERE
(multiple conditions) ?
Using where condition is the best choice because this query will run faster that the first one. Indexes on the fields that appear in WHERE or GROUP BY or ORDER BY clauses are most of the time useful. Loading all data before filter is better that loading the filtered data :)
Its better to fetch data using WHERE clause because it will boost your system performance in terms of time and load. Because if you use "select * " then that will consume more time and after that you have to waste further time to use that records as per your needs. So again you have to write code for that.
Where
is the better solution. If you would like to do it in php
you have to load all data from database before you can filter the data. In database you can add an index which makes the filtering performence better.
I think it also depends on how many time you need to call that mysql query to fetch result.
SO if you call that only once then yes WHERE clause is better solution
But if it require you to make multiple server call to fetch filterd data using mysql query then I think the first one approach will be better than this I.e Select all rows from a table and then filter the results with PHP
I hope it help you :)