473,411 Members | 1,899 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,411 software developers and data experts.

SQL query to check against a list

SQL gurus...

I have one table of items that is the master file. We will call this Table A.
I have another table that contains few, some or all items from Table A. We
will call this Table B.

I want to run a query that compares the list of items on Table B against the
master list on Table A.

If the item is not present on Table B, show it in the SQL results.

Best way to achieve this? I am looping and doubling results in my sql tries.

Jeff

--
Message posted via http://www.sqlmonster.com
Jul 23 '05 #1
1 2392

"Jeffrey Sheldon via SQLMonster.com" <fo***@nospam.SQLMonster.com> wrote in
message news:4F***********@SQLMonster.com...
SQL gurus...

I have one table of items that is the master file. We will call this
Table A.
I have another table that contains few, some or all items from Table A.
We
will call this Table B.

I want to run a query that compares the list of items on Table B against
the
master list on Table A.

If the item is not present on Table B, show it in the SQL results.

Best way to achieve this? I am looping and doubling results in my sql
tries.

Jeff

--
Message posted via http://www.sqlmonster.com


If you want all the items in A which do not have a corresponding row in B,
then this should work:

select
a.col, a.col2, ...
from
dbo.a a
where
not exists (
select *
from dbo.b b
where a.keycol = b.keycol)

Simon
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andromeda | last post by:
I have two tables... one contains all the loan officer information (name/address/phone/email/etc) the other is a NH license table which lists has 3 columns - txtLOName, dtDateHireSent,...
3
by: etwebbox | last post by:
Hoping someone has some ideas on how to solve this issue: I have a macro in excel which runs a query against an Access DB (it actually calls a query inside of Access). The query is not bringing...
8
by: Jerim79 | last post by:
I am working on a script that will query a database for a FNAME/LNAME combo. If it finds the combo, I need it to do one set of instructions. If it doesn't find it, I need it to do something else....
9
by: bubbles | last post by:
Newbie transiting from VBA to TSQL, using SQL Server 2005 Enterprise: Need help to do this: Open Table_A WITH TableA DO UNTIL .EOF Read value from TableA.ColumnA Run SQL Statement on...
21
by: tizmagik | last post by:
Database consists of the following 4 tables with respective attributes: CUSTOMER(C#, CUSTOMER NAME, ADDRESS), the key is ITEM(I#, ITEM NAME, MANUFACTURER, YEAR), the key is BOUGHT(C#, I#,...
21
by: Tarscher | last post by:
Hi all, I have events containing attendees (events has many attendees). The attendee table tells whether a user will attend the event or not. I want to build a query that returns all the...
15
by: Widge | last post by:
Hi, I wondered if you could help me with an issue I'm having. Currently I have a rebate calculation that is running off two tables: 1) A list of suppliers and the rebate %ages relevant to them...
1
by: jmarcrum | last post by:
Hey everyone, I have a question that's been troubling me for a bit. I work for Alabama Power. I have 1 table (tblOutages). Every morning I import a list of Power Outages for the state of...
1
by: shapper | last post by:
Hi, On a form I have an input where tags are inserted in a CSV format. Then on my code I convert the CSV string to a List<Tag>. Tag is an object with two properties: TagID and Name So when I...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.