How to join tables and get ppl not in the list of the other table

Hi, I have 2 tables

Table (girlscoutid, quarter, point)

Table b (girlscoutid, fname lname)

I want to get the names of ppl who didn't sell any point/s for Q4

girlscoutid agenda quarter
7771drinks4QS
9000Tickets4QW
7771Cookies2QS
5085books3QF
3010Tickets3QW
5085Cookies1QF

lscoutid fname lname
7771JennRichochet
9000LauraWilkins
5085SallyMae
3010DoraMcKenzie

That's what I have, however, I get duplicates and also 7771 appears on the list even if she sold something on the 4th quarter. Any suggestions?

SELECT fname, lname, a.girlscoutid

Of a, b

WHERE a.girlscoutid = b.girlscoutid

AND the term NOT AS "4Q_";

Hello

So, all the information that you want to see figure in table b, but if you want to see it depends on the table has.

This looks like a job for a semi Join.  Here's a way to do it:

SELECT b.fname

b.lname

b.girlscoutid

B

LEFT OUTER JOIN has IT a.girlscoutid = b.girlscoutid

AND a.quarter NOT AS "4Q_" - or a.TERM, if it is the column

WHERE a.girscoutid IS NULL

;

What you posted was an INNER join, where the rows of each table are included in the only game that if they have a corresponding row in the other table.

An OUTER join includes all the rows in a table (table b in this case) if they have a match in the other table.  If a line of b has no corresponding row in a, then all the columns that are supposed to come from table will be NULL in the result set.  Given that the join condition includes = b.girlscoutid a.girlscoutid, this means that the only way to a.girlscoutid can be NULL in the result set is if the b line is included although it has no corresponding line one, which are exactly the lines that we want to display.  (You can try to run the query above with the WHERE clause, deleted, just to see how it works.)

Alternatively, you can get the desired results by using a subquery NOT EXISTS, a NOT IN subquery or analytical functions.  The semi join, supra, is probably the most effective solution.

Tags: Database

Similar Questions

Maybe you are looking for

  • I don't get a password reset confirmation email.

    After triple verification of the entered e-mail address I so that the duration and Trash files I do not receive the password reset email link... I am on Windows 7, Version of Pale Moon: 25.2.1 (x 64). Tried to get that resolved on Firefox 36.0.1 - bu

  • e-mail failure to download the converted from Pages to Word documents

    Why attachment documents are converted to Pages in Word do not download?

  • "DVD player" BUG (needs updating)

    DVD player App version: 5500.66 Build: 5,560 (3) So, the problem is the following. When you create your own bookmarks, I found you can't delete or rename the 'cue/framework', it is a mistake that should be easily resolved. You need to be able to rear

  • DAQmX does not appear in Labview 8.5

    Story: Got fed up with Vista and downgraded to XP SP2. Reinstalled Labview, Measurement Studio, then DAQmX 9.4 (downloaded the last of the site NOR). Measurement Studio seems to load DAQmX tasks correctly even though I'm scared to compile in the case

  • compatibility of Nexus 5 with MDR-NC31EM

    I have a nexus 5. now I would like to purchace Digital Noise Cancelling Headphones MDR-NC31EM. I know that nexus 5 a 5 pin 3.5 mm jack, but I don't know that it is enabled in kernel or operating system level. so, I would like to confirm if the MDR-NC