General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 15th, 2008, 05:59 AM
Marcielo Marcielo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 6 Marcielo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 36 m 40 sec
Reputation Power: 0
Unique id's

HI there
I'm not sure how to explain this, but here it goes.
I have 2 forms, A and B, with few different fields, and a administration Aa and Bb. So what I want is to join Aa and Bb. In my former thread: Table INNER JOIN
I succeeded joining Aa and Bb, but I encountered a problem since submitted forms A and B have independent ID's and don't take 'consideration' to each others ID numbers. I mean ID numbers overlap. So how do I do to give them unique ID's?
Did it make sence ?

Reply With Quote
  #2  
Old June 15th, 2008, 09:43 AM
dykebert's Avatar
dykebert dykebert is offline
Contributing User
Click here for more information
 
Join Date: Apr 2008
Posts: 429 dykebert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 Days 30 m 5 sec
Reputation Power: 3
I'm not exactly sure what problem you are trying to solve.

1. Is the problem that you have 2 tables that have some data in common and some fields not in common and you want to see all the data?

For example:
tableA
firstName
LastName
Phone

tableB
FirstName
LastName
Address
city
state

any you want to see:

firstname, lastname, phone, address, city, state

2. You have 2 tables that have similar data structures (fields that are common to both) but different data sets and you want to see all of the data?

For example:

table A
FirstName, LastName
Barney, Rubble
Fred, Flintstone

table B
FirstName, LastName
Harry, Potter
Ron, Weasley

and you want:

FirstName, LastName
Barney, Rubble
Fred, Flintstone
Harry, Potter

Or is it something else?

A small sample of what you have and what you want will help.
Ron, Weasley

Reply With Quote
  #3  
Old June 15th, 2008, 11:04 AM
Marcielo Marcielo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 6 Marcielo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 36 m 40 sec
Reputation Power: 0
What I want is something like option 2

Table A:

ID: is not something you can fill in but a number that automatic ascends with the number of forms submitted.
Subject: fill in
Date: submitted

Table B:

ID: is not something you can fill in but a number that automatic ascends with the number of forms submitted.
Subject: fill in
Date: submitted


Administration of A and B

ID Subject Date
1 tableA xx-xx-xx
1 tableB xx-xx-xx

So the conflict comes with the ID. What I want is:

ID Subject Date
1 tableA xx-xx-xx
2 tableB xx-xx-xx

I hope this was more illustrative

Reply With Quote
  #4  
Old June 16th, 2008, 07:48 AM
dragonbite dragonbite is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Location: Connecticut, USA
Posts: 42 dragonbite User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 16 m 9 sec
Reputation Power: 3
New Column

Are you just displaying them all together in one location? If so why not use a UNION join and even add a column to determine which table it is coming from.

SELECT 'TableA' as 'source', ID, Subject, Date
FROM TableA
UNION ALL
SELECT 'TableB', ID, Subject, Date
FROM TableB
SORT BY ID, source

That way it takes the two tables and grabs all of the records from each and combines into one table.

One thing to watch out for:
+ the Columns have to match in type
+ the columns will be called whatever is defined in the FIRST select
+ UNION ALL will display all records, even if they are duplicates while UNION will not

Reply With Quote
  #5  
Old June 16th, 2008, 12:00 PM
Marcielo Marcielo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 6 Marcielo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 36 m 40 sec
Reputation Power: 0
Great idea thanks a lot

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > Unique id's


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.


© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 8 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek