etrader Posted November 3, 2011 Share Posted November 3, 2011 I have a normalized database in the form of ID user_id key value 1 3 first_name Brian 2 3 last_name Tardy 3 4 first_name John 4 4 last_name Wilson What is the fastest way to capture these values within php? I want to perform a SELECT to catch the values for every user as $result=mysql_query("SELECT * FROM users_data WHERE user_id = '$id'"); while($row=mysql_fetch_array($result)) { here we process all data for a given user and write it to text file as a single line } Since it is a long list (100K users with about 10M of rows in user_data), I am looking for the fastest and most reliable way to scan all the database. ?> Quote Link to comment https://forums.phpfreaks.com/topic/250350-reading-normalized-mysql-database-keyvalue/ Share on other sites More sharing options...
Zane Posted November 3, 2011 Share Posted November 3, 2011 It is beyond me why you would store user information like that when you could just as easily create another field for every key you have listed there. Doing that would cut your projected row count by at least 75% if not more.. But if you really want to get data out like that, then you would just use a query to filter by userid.. then use a foreach to assign the values to a multidimensional array. Quote Link to comment https://forums.phpfreaks.com/topic/250350-reading-normalized-mysql-database-keyvalue/#findComment-1284514 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.