473,388 Members | 1,207 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

SELECT 'NOT IN' question

Hi
I have 2 tables in this particular question:
1) Students
BCSID
SFIRST etc....

2) CandidateRef
CANDIDATEREFID
BCSID
EBID

Requirement:
I want to query Students, identifying records who are NOT IN CandidateRef, and EBID NOT=1, as the student record may exist but EBID may be = 2 and that is OK.

I used the Wizard that created the following SQL but can not make a distinction where EBID is concerned so I just get all student records that have not got a record in CandidateRef, but those records could be EBID=2 and they should not be excluded. Also I expected to see something like a 'NOT IN' statement but that is not what the Wizard created.

Current SQL:
Expand|Select|Wrap|Line Numbers
  1. SELECT Students.BCSID, Students.SFirst, Students.SOther, Students.SLast
  2. FROM Students LEFT JOIN CANDIDATEREF ON Students.[BCSID] = CANDIDATEREF.[BCSID]
  3. WHERE (((CANDIDATEREF.BCSID) Is Null));
Any ideas would be appreciated.
David
Jun 14 '10 #1
4 1899
patjones
931 Expert 512MB
Are you saying that you want 1) all the people who appear in the Students without appearing at all in CandidateRef, plus 2) all the people in CandidateRef with EBID <> 1?

It makes sense to me if this is the case. However it would be impossible for a particular person to fulfill both these conditions.

Pat
Jun 14 '10 #2
Kind of I guess:..best by example
students: BCSID, FULLNAME
1, fred bloggs
2, sam smith
3, arthur c clark
4, mickey mousa

candidateref: CID, BCSID, EBID
1, 2, 2
2, 4, 1

so I want the resulting select to return student records :
1, 2, 3 BUT NOT 4 as its EBID = 1

Am I making this more complicated than it really is???
Jun 14 '10 #3
Finally got it!!!
Expand|Select|Wrap|Line Numbers
  1. SELECT Students.BCSID, Students.SFirst, Students.SOther, Students.SLast, Students.Sadd1, Students.SAdd2, Students.SCity, Students.SGovernate, Students.SHomePhone, Students.SMobile, Students.SEmail1, Students.SCHOOLID, Students.chkselected
  2. FROM Students
  3. WHERE (Students.BCSID) Not In (SELECT candidateref.bcsid
  4. FROM candidateref
  5. WHERE ((candidateref.EBID)=[Forms]![frmstudentbulkboardalloc]![cmbboard]));
Thanks. D
Jun 14 '10 #4
patjones
931 Expert 512MB
@gingernob
Happy to see that you got it!

Pat
Jun 15 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Chris Farmer | last post by:
Hi. I have a newbie question about struts and the html:select tag. I can successfully populate a bean with an array of things and have those properly displayed in my html select box, but I can't...
4
by: Cyrille \cns\ Szymanski | last post by:
Hello, I have a XML document which is typically : <course> <section> <title>Foo</title> There comes the text </section> <section>
1
by: Carl Wu | last post by:
Hi all, I am newcomer in HTML, Javascript, I want to create two select controls S1, S2. There are 3 options: ALL, A, B in S1; When select A in S1, It let you select A1, A2 in S2,
1
by: e_AK_05 | last post by:
I have a question and I can't figure out how to do it. I have a select statment : SELECT table1.* AS table1.*, table2.* AS table2.* FROM table1, table2 WHERE 1 this does not work...for me at...
8
by: VM | last post by:
If I want to run this query ( " col_output like '<del> *BOX' " ), it'll throw an exception. How can I search for any rows that begin with '<del>' and end with 'BOX'? Would it also be possible to...
4
by: Kris Rudin | last post by:
I am displaying a table of information on a web page, using an asp:table that I populate dynamically. On this page I give the user the options to group the rows by certain fields, and/or filter the...
2
by: Lars Netzel | last post by:
This code works: SELECT * INTO #Temp From tbl_employee SELECT * FROM #Temp Drop TABLE #temp This does not: SELECT * INTO #Temp From (Select * FROM tbl_employee WHERE EMP_ID = @id UNION Select...
1
by: Anton Nikiforov | last post by:
Dear All, could you please help me with writing select statment for the following: I have two tables dictionary_text label| Text -----+------------------------ 23 | General 24 | Internet...
9
by: Udo Marx | last post by:
Greets to ciwah! I'm doing a little webproject for a local session event. Tryin' to meet latest standards i failed to do this: --snip-- <select name="fromcountry" accesskey="l" title="+">...
1
by: hazelra | last post by:
Can Access do a "SELECT * NOT IN SELECT..." kind of query? What is the proper syntax?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.