Jump to content

Issue related to SQL


kirankumar341
 Share

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...