| | |
Getting data from multiple table issue
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
Hello...
I need to get data from one table while omitting data that exist in the other table. This is the query I am running but I keep on getting duplicates since there are more the one row in the second table.
Table1 - 'countries' with fields 'Country_Code' and 'Country_Name'
Table2 - 'allow' with field 'Country_Code'
Since there are multiple rows in table2(allow) I get duplicate results.
Any help would be appreciated.
I need to get data from one table while omitting data that exist in the other table. This is the query I am running but I keep on getting duplicates since there are more the one row in the second table.
Table1 - 'countries' with fields 'Country_Code' and 'Country_Name'
Table2 - 'allow' with field 'Country_Code'
MySQL Syntax (Toggle Plain Text)
SELECT countries.Country_Code, Country_Name FROM countries, allow WHERE countries.Country_Code != allow.Country_Code ORDER BY Country_Name
Since there are multiple rows in table2(allow) I get duplicate results.
Any help would be appreciated.
Ok, I think I am a little lost lets put some data into that table
COUNTRIES
USA - UNITED STATES
DR - DOMINICAN REPUBLIC
MX - MEXICO
PR - PUERTO RICO
ALLOW
DR
MX
So what you are saying is that in ALLOW table you can have multiple DR and MX?
COUNTRIES
USA - UNITED STATES
DR - DOMINICAN REPUBLIC
MX - MEXICO
PR - PUERTO RICO
ALLOW
DR
MX
So what you are saying is that in ALLOW table you can have multiple DR and MX?
If your already resolved your issue, flag it as solved.
José Bisonó
José Bisonó
That is exactly how my tables are set up. the problem is that I want to get the Country Name along with their Country Code, but I do not want that information for the countries which are in the allow table. in this case DR and MX.
With that table data above, I would run the query to get only these records:
RESULTS
USA - UNITED STATES
PR - PUERTO RICO
With that table data above, I would run the query to get only these records:
RESULTS
USA - UNITED STATES
PR - PUERTO RICO
![]() |
Similar Threads
- result multiple table data? (PHP)
- data from multiple tables (VB.NET)
- Error encountered while searching for data from access table (Visual Basic 4 / 5 / 6)
- Error in display multiple table record in datagrid (VB.NET)
- filling combobox with data stored in a table in sql server (VB.NET)
- How to save data from a variable to a table. (PHP)
- Convert XML data to sql table through coding in ASP.Net2.0 (IT Professionals' Lounge)
- MySql multiple table query problem.... (MySQL)
Other Threads in the MySQL Forum
- Previous Thread: compare 2 columns with wildcard
- Next Thread: SQL problem
| Thread Tools | Search this Thread |
Tag cloud for MySQL
1 agplv3 alfresco api artisticlicense aws bizspark breathalyzer camparingtocolumns cmg communityjournalism contentmanagement contractors copyright count court data database design developer development distinct drupal dui ec2 email enter enterprise error eudora facebook form foss gnu government gpl greenit groklaw hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire law legal license licensing maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php query referencedesign reorderingcolumns resultset saas search select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency update virtualization





