473,466 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Picking latest 'duplicate' entry and linking to second table

2 New Member
I think I have a straight forward requirement here but cannot seem to work out the logic.

I have 2 tables with the following columns

SERVERLICENSE
licenseid,licensekey,createddate,status (active or dormant)

TOOLICENSE
toollicenseid,licenseid,toolname,licensekey,create ddate

The tables are linked via the licenseid. Typical data is:

SERVERLICENSE
1,1235-2563,10/01/11,dormant
2,5685-5365,05/01/12,active

TOOLLICENSE
1001,1,smtp,adfg-fgbh,10/01/11
1002,1,odbc,erth-bgfh,10/01/11
1003,1,html,rfgt-dsww,10/01/11
1004,2,word,edfg-tghj,05/01/12
1005,2,smtp,wwsk-plon,05/01/12

From this data you can see that some of the tools are linked to Serverlincense 1, others are against serverlicense 2, and an updated toollicense has been created against serverlicense 2.

I want to update the toollicense table (or create a new one) that combines the distinct tools and latest updated tools and links them to the latest server license. This means I will end up with the folloing TOOLLICNSE table

TOOLLICENSE (NEW)
1002,2,odbc,erth-bgfh,10/01/11
1003,2,html,rfgt-dsww,10/01/11
1004,2,word,edfg-tghj,05/01/12
1005,2,smtp,wwsk-plon,05/01/12

SO the odbc & html tools have bbeen updated to link to serverlicense 2, and the earlier smtp tool has not been imported into the new table.

Hope this makes sense...

Thanks

Steve
Mar 5 '12 #1
2 1667
Rabbit
12,516 Recognized Expert Moderator MVP
I would take the max tool id by each tool name and use an inner join to filter down to the most recent records. Then, for the license id, you just need to select the max license id.
Mar 5 '12 #2
steveclements
2 New Member
Thanks for the reply Rabbit, I'll take you suggestions and try them out
Mar 6 '12 #3

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

Similar topics

0
by: jjliu | last post by:
i have a table with two fields (id and myfield). id is a primary key not nll auto_increment, and myfield is set as unique... Due to unique setting for myfield, if i try to insert the duplicate...
0
by: Gary Lundquest | last post by:
I have an application with MS Access 2000 as the front end and MySQL as the back end. All was well until I upgraded the MySQL (Linux) server. The Problem: I insert data into a cumulative table....
0
by: lynn | last post by:
Hello, I am installing some databases on the mysql databases of my mac osx 10.2.8 but when I do "mysqlimport -u X -p W (directory) *.txt.table" I am getting this answer: mysqlimport: Error:...
4
by: newsfan | last post by:
I get that error when I try to update a table in my database This is my table +----+------------+---------+-----------+ | ID | CPRNR | NAME | SURNAME |...
8
by: Iona | last post by:
Hi Allan, I'm using a nifty piece of code you put on here some time back to do a duplicate entry check as below. I'm using to check for duplicate names. However I am getting an error message on...
3
emandel
by: emandel | last post by:
In my DB I have an Events Table, a Participants table, and a attendance table. The attendance table is the junction table that connects the other two (many to many). So in the attendance tale, I...
5
by: baur79 | last post by:
Hi guys i try to run this code in loop and to pass even the entry is duplicated def email_insert_in_db(email): sql="INSERT INTO emails (email) values ('%s') "%(email)...
3
by: patelxxx | last post by:
I'm trying to update a template on our Content Management System, however getting the following error. I know its difficult to know what the problem is without looking at the PERL coding, however...
1
by: chicago1985 | last post by:
I have a unique constraint in my Oracle table for 3 fields. If I enter duplicate info on the table using Oracle client I will get an Ora message error ORA-00001 that tells me it is a duplicate entry...
2
by: olcaygul | last post by:
hii i´m learning jsp and html with sql and i´m beginer on it, i have the table andcodes below in mysql and jsp, i´m working on html and jsp with netbeans IDE 3.6. of course if i try to insert any...
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:
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,...
0
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...
0
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...
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
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...
0
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...
0
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 ...

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.