I feel stupid for asking this, but
Say I have a table with a massive number of entries (for example, 10000). Say this table has a column that has at least 5000 unique values in it.
Would it be better to simply select EVERYTHING from this massive table and then loop through the resulting array and find the correct rows with PHP, or to use a massively long SELECT statement such as
SELECT * from massive_table where value like "1524" OR value like "5614" ... OR value like ...
...that specifies every entry in the list of values, thereby decreasing the number of rows returned? The latter approach would have me using a PHP loop all the same, but to form the query rather than to process the array.
My brain is fried and I feel like I'm missing something / there must be a less stupid way to do this. I readily admit this is stupid. Any help? >_<
Say I have a table with a massive number of entries (for example, 10000). Say this table has a column that has at least 5000 unique values in it.
Code:
I have a list of specific values for the "value" column somewhere else. id | ... | value| ... ---------------------------- 0 | ... | 5231 | ... 1 | ... | 1603 | ... . | | | . | | | . | | | 10000 | ... | 4614 | ...
Code:
I want to select all the rows in the table that contain a value that matches ANY ENTRY in that list. 1524 5614 5231 . . .
Would it be better to simply select EVERYTHING from this massive table and then loop through the resulting array and find the correct rows with PHP, or to use a massively long SELECT statement such as
SELECT * from massive_table where value like "1524" OR value like "5614" ... OR value like ...
...that specifies every entry in the list of values, thereby decreasing the number of rows returned? The latter approach would have me using a PHP loop all the same, but to form the query rather than to process the array.
My brain is fried and I feel like I'm missing something / there must be a less stupid way to do this. I readily admit this is stupid. Any help? >_<
一个大西瓜