bddotnet Posted March 9, 2014 Share Posted March 9, 2014 I have a database table of the states with abbreviations. I have another table that has my amateur radio contacts by state. I want to output the abbreviation of the states for which I do not have a contact with. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/286835-records-for-each-state-in-usa/ Share on other sites More sharing options...
ginerjm Posted March 9, 2014 Share Posted March 9, 2014 Do a join using states and a sub-query getting say, the count of contacts by state and output the state, name, and count. Then loop thru the results and only output those that have a zero count Quote Link to comment https://forums.phpfreaks.com/topic/286835-records-for-each-state-in-usa/#findComment-1471932 Share on other sites More sharing options...
bddotnet Posted March 9, 2014 Author Share Posted March 9, 2014 OK. Here's the layout: Table1 has the abbreviations of each of the 50 states. variable name is state_abbreviation Table2 has the contact information. variable name is contact_state I want to only output the state_abbreviations in Table2 that don't have a record in Table1 that matches. SELECT * JOIN table1, table2 WHERE COUNT..... am I heading in the right direction? Quote Link to comment https://forums.phpfreaks.com/topic/286835-records-for-each-state-in-usa/#findComment-1471941 Share on other sites More sharing options...
ginerjm Posted March 10, 2014 Share Posted March 10, 2014 Not really. You need to google some sql learning and see how to do a join between two tables. (Part of the 'learning' process). Quote Link to comment https://forums.phpfreaks.com/topic/286835-records-for-each-state-in-usa/#findComment-1471960 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.