kirankumar341 Posted June 8, 2013 Share Posted June 8, 2013 Friends, i have 3 tables.....one named stocklist, other one....partyinsrcd, 3rd one.....sregisteri would like to select distinct vehicle model name from table stocklist whose related chassis numbers not available in the other two tables.......please help...Is this the sql for the above....pl check. i am not getting the result from the below sql......SELECT distinct stocklist.vehicle FROM (stocklist inner JOIN sregister ON stocklist.chassissregister.CHASSIS) inner JOIN partyinsrcd ON stocklist.chassisright(partyinsrcd.chassisno,7) WHERE (((sregister.CHASSIS)stocklist.chassis) and (right(partyinsrcd.chassisno,7)stocklist.chassis) Link to comment Share on other sites More sharing options...
justsomeguy Posted June 10, 2013 Share Posted June 10, 2013 This syntax doesn't look right: WHERE (((sregister.CHASSIS)stocklist.chassis) and (right(partyinsrcd.chassisno,7)stocklist.chassis) There aren't enough parentheses, but that first condition doesn't make sense. Either way, an inner join is going to exclude rows that don't have a match. If you're looking for rows that don't have a match then you can either use a left join and only get the rows that have nulls, or use a subquery. SELECT distinct stocklist.vehicle FROM stocklist WHERE stocklist.chassis NOT IN (SELECT chassisno FROM partyinsrcd UNION SELECT chasses FROM sregister) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now