I'm in need of a little sql help.
How do i get a list of ids from one table that do not have the same ids in
another table?
I hope that makes sense. 2 3233
Dave wrote:
I'm in need of a little sql help.
How do i get a list of ids from one table that do not have the same ids in
another table?
I hope that makes sense.
not exact syntax, but gives you an idea...
select a.id, b.id from table1 a left join table2 b on a.id=b.id where b.id is null;
mysqlcreate table t1 (c1 integer);
Query OK, 0 rows affected (2.27 sec)
mysqlcreate table t2 (c1 integer);
Query OK, 0 rows affected (1.60 sec)
mysqlinsert into t1 values (1),(2),(3),(4) ,(5);
Query OK, 5 rows affected (0.24 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysqlinsert into t2 values (1),(2),(4),(5) ;
Query OK, 4 rows affected (0.15 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysqlselect t1.c1,t2.c1 from t1 left join t2 on t1.c1=t2.c1 where t2.c1 is null;
+------+------+
| c1 | c1 |
+------+------+
| 3 | NULL |
+------+------+
1 row in set (0.10 sec)
--
Michael Austin.
DBA Consultant
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Thanks very much Michael, that's exactly what i need.
"Michael Austin" <ma*****@firstd basource.comwro te in message
news:rs******** *********@newss vr21.news.prodi gy.net...
Dave wrote:
>I'm in need of a little sql help.
How do i get a list of ids from one table that do not have the same ids in another table?
I hope that makes sense.
not exact syntax, but gives you an idea...
select a.id, b.id from table1 a left join table2 b on a.id=b.id where b.id
is null;
mysqlcreate table t1 (c1 integer);
Query OK, 0 rows affected (2.27 sec)
mysqlcreate table t2 (c1 integer);
Query OK, 0 rows affected (1.60 sec)
mysqlinsert into t1 values (1),(2),(3),(4) ,(5);
Query OK, 5 rows affected (0.24 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysqlinsert into t2 values (1),(2),(4),(5) ;
Query OK, 4 rows affected (0.15 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysqlselect t1.c1,t2.c1 from t1 left join t2 on t1.c1=t2.c1 where t2.c1
is null;
+------+------+
| c1 | c1 |
+------+------+
| 3 | NULL |
+------+------+
1 row in set (0.10 sec)
--
Michael Austin.
DBA Consultant
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Philip Mette |
last post by:
I am begginner at best so I hope someone that is better can help.
I have a stored procedure that updates a view that I wrote using 2
cursors.(Kind of a Inner Loop) I wrote it this way Because I couldn't
do it using reqular transact SQL.
The problem is that this procedure is taking longer and longer to run.
Up to 5 hours now! It is anaylizing about 30,000 records. I think
partly because we add new records every month.
The procedure...
|
by: U N Me |
last post by:
I have a continuous form that lists records from a query. One of the
columns is an amount field, In the footer of the form I place a text
box that displays the total (sum) of the amount.
The data in the form is linked from a one-to-many table relationship.
In this instance, I really can't sum the value from the one's table
since if there were 3 records in the many table for a record id, the
value would be summed 3 times. IOW, I may be...
|
by: Beat Scheidiger |
last post by:
I do not quite understand this property. Everything is seems clear to
me, when I read the corresponding help text.
But in practice I have a question: Why are there 3 identical records
in the following query (with property 'Unique records' = Yes)?
SELECT DISTINCTROW tblCustomer., tblCustomer., tblCustomer., tblOrders.,
tblOrders., tblOrders.Artikel FROM tblCustomer INNER JOIN
tblOrders ON tblCustomer. = tblOrders.;
|
by: Marie |
last post by:
Access97
I have a table containing addresses with a separate field for State. Is there a
way to create a query that returns an unique list of the states in that table
and still be updateable? I tried setting the unique values property to Yes but
that gave me a recordset that was not updateable.
Thanks!
Marie
|
by: Phil |
last post by:
I am looking to set up a hyperlink control on a form to retrieve letters
that correspond to a record on a form. That is, there may be 100 form
records, and I would like each of those form records to have a hyperlink
button or control on it. that when pushed, pulls up the unique Word document
associated with that form record. In this example, there would 100 unique
letters associated with 100 unique form records. I tried working with...
| |
by: Siv |
last post by:
Hi,
I seem to be having a problem with a DataAdapter against an Access database.
My app deletes 3 records runs a da.update(dt) where dt is a data.Datatable.
I then proceed to update a list to reflect that the 3 items have been
deleted only to discover that the 3 items appear, however when I click on
them to display their information which runs a datareader over the same
database it appears that the data has now gone.
I wondered whether...
|
by: ET |
last post by:
Hi!
I'll need help on what todo with this information in table...
There has to be a unique on one column (Item ID, for inventory purpose)
but in many cases that ID is not known... thus, many empty records for
that column exist in a table.
I tried to create unique index (no duplicates), of course, it failed
because of many empty records...
Now, is there ANY way to keep those empty records, and allow new empty
|
by: Lennart Anderson |
last post by:
I'm having a MySQl table wih a lot of information. I want to present some
main fields in a table on one page. Each record do, of course, have a unique
ID. The presnted table will have one field as a linked field. I want to be
able to click this link, retreive the ID information for that record and
then present detailed data for that record on the next page.
How do I retreive the ID?
Any hints are very much appreciated.
Thanks
|
by: banderson |
last post by:
Hello,
I have a data entry form for a table with information about buildings and am having a problem making a combo box do what I want. I would like to make the combo box show a list of unique bldg mgmt company names and then to open a building management company form to show all records with this name, so the user can find the correct branch location to select. Then, upon closing the building management company form, the active/selected record...
|
by: srusskinyon |
last post by:
I need some help getting unique records from our database! I work for
a small non-profit homeless shelter. We keep track of guest
information as well as what services we have offered for statistical
purposes.
I've been using
Here's the situation:
I have two main tables:
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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,...
|
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...
|
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,...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |