• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

Mysql query. Populate drop down menu with results which are not in a table

Hi Experts,
I am trying to write a query that populates a dropdown menu.
I need to filter out records that exist in one table and only show the rest of the records that dont exist. I cant seem to get this working.

When I switch the where clause I identify all the records I want to exclude
WHERE
properties.Prodtypeid = cases.Prodtypeid

How does one write the query propely
SELECT
properties.Prodtypeid,
properties.ProductName
FROM
properties
Left Outer Join cases ON cases.Prodtypeid = properties.Prodtypeid
WHERE
properties.Prodtypeid <>  cases.Prodtypeid

Open in new window

0
matthewdacruz
Asked:
matthewdacruz
1 Solution
 
me655321Commented:
Here, try this code. I assumed you wanted table cases excluded, but maybe it was the other way around. Also not sure if you still wanted the join, even excluding with this method. Anyway, this should be what you're looking for.
select Prodtypeid, ProductName from properties where not exists (select * from cases where properties.Prodtypeid = cases.Prodtypeid)

Open in new window

0
 
matthewdacruzAuthor Commented:
Thanks me655321

That did the trick
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now