Avalanche Posted September 12, 2003 Share Posted September 12, 2003 Okay, I am making a membership system, and there are two tables for the members. One is tbl_users (has username, password, email, and rank), and the other is tbl_userinfo (has 10+ columns of other information). So, I split it up into two different tables so it wouldn\'t get to be a ginormous table. The rank that I mentioned in tbl_users can be admin, user, or unset. \"Unset\" means that the account hasn\'t been verified yet, and it doesn\'t let you log in if your account is \"unset.\" Now, on the page where it lists the users (but doesn\'t have the whole profile) it uses information only from the tbl_userinfo, and doesn\'t draw anything from tbl_users. However, I need it to only select users information from tbl_userinfo where their rank in tbl_users is not \"unset.\" I\'m not sure exactly how I could do this with my current table setup. Would I just have to move the rank over to tbl_userinfo? I you are able to understand what I mean. Thanks. PS: I have an id_key in the tbl_users, and a parent_id_key in the tbl_userinfo that are identical for each account. Quote Link to comment https://forums.phpfreaks.com/topic/1009-need-help-with-two-tables/ Share on other sites More sharing options...
effigy Posted September 12, 2003 Share Posted September 12, 2003 hmm. can we get some visuals? and the table structures? Quote Link to comment https://forums.phpfreaks.com/topic/1009-need-help-with-two-tables/#findComment-3416 Share on other sites More sharing options...
gizmola Posted September 12, 2003 Share Posted September 12, 2003 Okay, I am making a membership system, and there are two tables for the members. One is tbl_users (has username, password, email, and rank), and the other is tbl_userinfo (has 10+ columns of other information). So, I split it up into two different tables so it wouldn\'t get to be a ginormous table. The rank that I mentioned in tbl_users can be admin, user, or unset. \\\"Unset\\\" means that the account hasn\'t been verified yet, and it doesn\'t let you log in if your account is \\\"unset.\\\" Now, on the page where it lists the users (but doesn\'t have the whole profile) it uses information only from the tbl_userinfo, and doesn\'t draw anything from tbl_users. However, I need it to only select users information from tbl_userinfo where their rank in tbl_users is not \\\"unset.\\\" I\'m not sure exactly how I could do this with my current table setup. Would I just have to move the rank over to tbl_userinfo? I you are able to understand what I mean. Thanks. PS: I have an id_key in the tbl_users, and a parent_id_key in the tbl_userinfo that are identical for each account. You simply need to join the tables together. In SQL you are always returned a \"set\" ie. a table. Joining two or more tables together creates what you could think of as a temporary table. If I understand you correctly you have two tables that you can join by id_key and parent_id_key. So something like: SELECT * FROM table a, table b WHERE a.id_key = b.parent_id_key AND rank \'unset\' Quote Link to comment https://forums.phpfreaks.com/topic/1009-need-help-with-two-tables/#findComment-3418 Share on other sites More sharing options...
Avalanche Posted September 13, 2003 Author Share Posted September 13, 2003 So in my case it would be like: [php:1:ed34137c45]SELECT * FROM tbl_users, tbl_userinfo WHERE tbl_users.id_key = tbl_userinfo.parent_id_key AND rank!=\'unset\'[/php:1:ed34137c45] Also, would I have to put \"AND tbl_users.rank ...\"? Thanks a bunch! Quote Link to comment https://forums.phpfreaks.com/topic/1009-need-help-with-two-tables/#findComment-3419 Share on other sites More sharing options...
Barand Posted September 13, 2003 Share Posted September 13, 2003 Also, would I have to put \\\"AND tbl_users.rank ...\\\"? You shouldn\'t have any fields in both tables except the id (so you can join them) If you don\'t want password or email selected , you can be more selective by [php:1:81b203b108]<?php SELECT tbl_userinfo.*, tbl_users.username, tbl_users.rank FROM tbl_users, tbl_userinfo WHERE tbl_users.id_key = tbl_userinfo.parent_id_key AND rank!=\'unset\' ?>[/php:1:81b203b108] Quote Link to comment https://forums.phpfreaks.com/topic/1009-need-help-with-two-tables/#findComment-3420 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.