Jump to content

Issue related to SQL


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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...