If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
I am trying to run a simple sql query but must be doing something wrong. Basically there are two tables, one containing category information and another containing categories that should be blocked. I want to make a sql query that grabs all of the categories except those listed in the blocked list. Below is the sql string I used, instead of just the unblocked categories being returned it returns the rows of the unblocked categories and then another copy of all categories.
SQL String I am using:
"SELECT categories.catID, categories.catName FROM categories, blockedcategories WHERE categories.catID != blockedcategories.catID"
Data in categories table
catID | catName
----------------------
1 | Test Category
----------------------
2 | Test Category2
----------------------
3 | Test Category3
----------------------
4 | Test Category4
Data in blockedcategories table
catID
----------
1
----------
3
Data returned when I run my sql string
catID | catName
----------------------
2 | Test Category2
----------------------
4 | Test Category4
----------------------
1 | Test Category
----------------------
2 | Test Category2
----------------------
3 | Test Category3
----------------------
4 | Test Category4
Desired results if SQL string worked correctly
catID | catName
----------------------
2 | Test Category2
----------------------
4 | Test Category4