I have 2 tables: users and items. Each item has a user#. So, if I want to find only items associated with a particular user I can:
SELECT * FROM items WHERE user_id = “$user_id”;
But if there are thousands of items, searching through the table will take forever, right?
Is there a better way to go about doing this? Maybe a way to store all item numbers associated with a user into a field in the users table?
Thanks,
Jason
No, it won’t take forever. This is how it should be done, even if there were millions of records.
I noticed you quoted the user_id value… Isn’t it a number field? The quotes are not needed.
Obviously the user_id should be an indexed field.