jteixeira Posted May 2, 2007 Share Posted May 2, 2007 hi, I'am working with microsoft sql server express and i have 2 querys:1: select artigo,pvpfrom precos inner join clientes on clientes.tppreco=precos.linprcwhere artigo<>'' and clientes.numero=25 2: select codigo,pvpsivafrom artigoswhere codigo<>'' 1 results:artigo pvpAO022 5.8800CAFE 2.2400CCT49 32.9700CFA71 13.8100DFSTCOM 100.00002 results:codigo pvpsivaAO022 87.0000CAFE 0.0000CCT49 0.0000CFA71 17.4600DFSTCOM 0.0000DFSTCR 13.0000I want to create a new query that joins query 1 and 2 in one and return only the diferents results.In this case:codigo pvpsivaDFSTCR 13.0000 Link to comment Share on other sites More sharing options...
Yahweh Posted May 3, 2007 Share Posted May 3, 2007 I haven't tested it, but this should work: select artigo,pvpfrom precos inner join clientes on clientes.tppreco=precos.linprcLEFT JOIN artigoswhere (artigo<>'' and codigo <> '' AND clientes.numero=25) AND (artigo <> codigo AND pvpsiva <> pvp) I don't know what your table looks like, so I can't say if thats the most efficient query. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.