473,750 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Joins


Hi,

Table Oelsls contains all products bought (history) table Invt contains
the products to sell (Inventory) I'm trying with no success to list all
products in Oelsls table (field name in both tables: part_id) that are not
in the Invt table.

My objective is a grid of all Special (non inventory) products.

Can anyone produce the correct sql statement?

Thank you.
Jul 20 '05 #1
2 1811

"Joel" <jo**@ecsnj.com > wrote in message
news:mKfyd.7335 $152.4970@trndn y01...

Hi,

Table Oelsls contains all products bought (history) table Invt contains the products to sell (Inventory) I'm trying with no success to list all
products in Oelsls table (field name in both tables: part_id) that are not
in the Invt table.

My objective is a grid of all Special (non inventory) products.

Can anyone produce the correct sql statement?

Thank you.

Depends of the version of MySQL.

If you don't have subqueries then

create table BoughtItems(
ItemNumber tinyint unsigned not null primary key);

create table InventoryItems(
ItemNumber tinyint unsigned not null primary key);

insert into BoughtItems (ItemNumber)val ues(1),(2),(3), (10);
insert into InventoryItems( ItemNumber)valu es(1),(2),(3)

SELECT BoughtItems.Ite mNumber FROM BoughtItems
LEFT OUTER JOIN InventoryItems on InventoryItems. ItemNumber =
BoughtItems.Ite mNumber
where InventoryItems. ItemNumber is null;

If you do have subqueries, then:

SELECT ItemNumber FROM BoughtItems where ItemNumber not in(
SELECT ItemNumber FROM InventoryItems)

Regards,
Rich
Jul 20 '05 #2

Thank you Rich

I'm not yet familiar with sub queries But your first suggestion worked like
a charm!
"Rich R" <rr***@cshore.c om> wrote in message
news:ER******** ********@newssv r31.news.prodig y.com...

"Joel" <jo**@ecsnj.com > wrote in message
news:mKfyd.7335 $152.4970@trndn y01...

Hi,

Table Oelsls contains all products bought (history) table Invt

contains
the products to sell (Inventory) I'm trying with no success to list all
products in Oelsls table (field name in both tables: part_id) that are not in the Invt table.

My objective is a grid of all Special (non inventory) products.

Can anyone produce the correct sql statement?

Thank you.

Depends of the version of MySQL.

If you don't have subqueries then

create table BoughtItems(
ItemNumber tinyint unsigned not null primary key);

create table InventoryItems(
ItemNumber tinyint unsigned not null primary key);

insert into BoughtItems (ItemNumber)val ues(1),(2),(3), (10);
insert into InventoryItems( ItemNumber)valu es(1),(2),(3)

SELECT BoughtItems.Ite mNumber FROM BoughtItems
LEFT OUTER JOIN InventoryItems on InventoryItems. ItemNumber =
BoughtItems.Ite mNumber
where InventoryItems. ItemNumber is null;

If you do have subqueries, then:

SELECT ItemNumber FROM BoughtItems where ItemNumber not in(
SELECT ItemNumber FROM InventoryItems)

Regards,
Rich

Jul 20 '05 #3

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

Similar topics

6
2083
by: jgalzic | last post by:
Hi, I'm having trouble doing joins correctly on two tables. I've read up a lot about the different types of joins and tried lots of variations on inner, outer, and left joins with no avail. Something isn't correct with my logic so could anyone give me some pointers on it? I have 2 tables: CourseRoster: ID CourseID StudentID StudentType
3
6416
by: Prem | last post by:
Hi, I am having many problems with inner join. my first problem is : 1) I want to know the precedance while evaluating query with multiple joins. eg. select Employees.FirstName, Employees.LastName, TerritoryID, Employees.EmployeeID, RegionID, ProductID from Employees
4
3995
by: Sri | last post by:
I am writing a download process in which i have a condition where i need to join four tables. Each table have lot of data say around 300000 recs. my question is when i am doing the joins on the columns is there any specific order i need to follow.
1
4662
by: Prem | last post by:
Hi All Database Gurus, I am trying to write code which will produce all the possible valid queries, given tables and join information for tables. Right now i am just trying to construct all the sequential joins. eg. if i have 4 tables A, B, C, D and the join conditions are A Inner join B, B Inner Join C, C Left Outer join D then i am constructing joins as :
4
4107
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the results, then doing a self left join with those results, etc. What puzzles me is that the time required for the query seems to grow exponentially as I add additional left joins, which I didn't expect. I expected the inner select to return about 25...
4
2048
by: michaelnewport | last post by:
Greetings, I like to write my inner joins as below, but someone at work tells me its not as 'performant' as using the 'inner join' statement. Is this true ? Is there a better way to write it ? thanks
7
31562
by: Steve | last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three "Left Outer Joins" in order to return every transaction for a specific set of criteria. Using three "Left Outer Joins" slows the system down considerably. I've tried creating a temp db, but I can't figure out how to execute two select commands. (It throws the exception "The column prefix 'tempdb' does not match with a table name or alias name used in the query.")
2
19721
by: narendra vuradi | last post by:
Hi I have a requirement where in i haev to convert the SQL from Oracle to the one which will run on the SQL server. in the Oracle Query i am doing multiple joins, between some 13 tables. and some of these joins are inner joins and some are Left outer joins. table1 inner joined with table 2 table2 inner join with table3 table2 inner join with table4 table2 left join with table5
9
11920
by: shapper | last post by:
Hello, I am used to SQL but I am starting to use LINQ. How can I create Left, Right and Inner joins in LINQ? How to distinguish the different joins? Here is a great SQL example: http://www.codinghorror.com/blog/archives/000976.html
36
2493
by: TC | last post by:
I've used Access for many years. Several times, I've encountered a bug which I refer to as the "Vanishing Joins" bug. When it happens, joins vanish randomly from queries. More specifically, all joins vanish from at least one (seemingly random) query. I've always regarded the Vanishing Joins bug as a symptom of corruption. When it happens, I usually give my users advice on how to recover from corruption, and how to avoid it in the future....
0
8839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9584
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9397
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9344
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9257
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8264
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6081
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4716
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4893
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.