glennn.php Posted May 23, 2010 Share Posted May 23, 2010 i'm building a large db of Users who own more then one auto, for example. (LOTS more data, like various airlines they've used, etc. so there's more than one choice per user) i'm hoping someone might give me an idea how best to create INSERT and SELECT queries for Users who might own an Acura Legend and a Chevy Camaro. i have these tables: Makes with fields: ID, Make (contains many auto mfrs) Models with fields: ID, MakeID and Model (contains the respective models) Users ... what i can't get around is how to store data where Smith owns an Acura (1) Legend (5)(1) AND a Chevy Camaro - if someone helped me with a way to store this i could get the SELECT query myself. i considered storing an array in the user's row, i.e. user_makes (1,3) and user_models (5,12) and working with those arrays when i retrieve the data, but i'm really thinking there's a better way to do that. i hate arrays... i appreciate it much GN Quote Link to comment https://forums.phpfreaks.com/topic/202676-help-getting-started-with-a-large-db/ Share on other sites More sharing options...
jskywalker Posted May 24, 2010 Share Posted May 24, 2010 $idMake = Mysql_result(mysqlquery("SELECT id from Makes WHERE Make = 'Acura';")); $idModel = Mysql_result(mysqlquery("SELECT id from Models WHERE Make = 'Acura' AND Model='Legend';")); $sql = "UPDATE assets (user, make, mode) VALUES ('John', $idMake, $idModel);" something like above? Quote Link to comment https://forums.phpfreaks.com/topic/202676-help-getting-started-with-a-large-db/#findComment-1062624 Share on other sites More sharing options...
glennn.php Posted May 24, 2010 Author Share Posted May 24, 2010 i got it straight, thanks Quote Link to comment https://forums.phpfreaks.com/topic/202676-help-getting-started-with-a-large-db/#findComment-1062660 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.