Link to home
Start Free TrialLog in
Avatar of jonofat
jonofat

asked on

SQL JOIN

I have 2 tables that look like this

table_prodsize
prodsizeid | prodize
--------------  -------------

     16           X-small
     17           Small
     18           Medium
     19           Large


table_sizes

productid | sizeid
------------   ---------

      1          17
      1          18
      1          19

I am trying to get records to show that DON'T match. So basically X-small should show as it is the only one not in the table_sizes table but my query is not doing that. Pleas help!

SELECT *
FROM sizes INNER JOIN prodsize ON sizes.sizeid != prodsize.prodsizeid
WHERE productid = colname

colname:

$colname_rs_sizes = "-1";
if (isset($_GET['ProductID'])) {
  $colname_rs_sizes = $_GET['ProductID'];
}

Avatar of jonofat
jonofat

ASKER

sorry, that != is meant to be <>, i forgot to change it back...
ASKER CERTIFIED SOLUTION
Avatar of haloexpertsexchange
haloexpertsexchange
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jonofat

ASKER

Okay, you muddled the order around a bit so I tried it with the order I want and it worked like a charm! Great stuff, thanks so much! Points on the way..

SELECT *
FROM prodsize
WHERE prodsizeid not in (SELECT sizeid FROM sizes INNER JOIN prodsize ON sizes.sizeid = prodsize.prodsizeid WHERE productid = colname)