473,606 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with Complex joins

I need some help. Here is the problem.

Table_1 (gl_Train_KeyId eas)

+----------------------+----------------+-------------------+---------------+
| KeyIdea_ID | Unit_ID | Group_ID | Title |
+----------------------+----------------+-------------------+---------------+
| 1 | 1 | 27 | yada 1 |
| | | | |
| 2 | 1 | 27 | yada 2 |
| | | | |
| 3 | 1 | 27 | yada 3 |
| | | | |
| 4 | 1 | 27 | yada 4 |
| | | | |
+----------------------+----------------+-------------------+----------------+

Table_2 (gl_Train_Progr ess)

+----------------------+----------------+----------------------+
| ID | User_ID | KeyIdea_ID |
+----------------------+----------------+----------------------+
| 12 | 5 | 3 |
| | | |
| 11 | 5 | 2 |
| | | |
| 10 | 5 | 1 |
| | | |
+----------------------+----------------+-----------------------+
The following sql returns field KeyIdea_ID = 4 which is the only
KeyIdea not in both tables.

SELECT gl_Train_KeyIde as.KeyIdea_ID
FROM gl_Train_KeyIde as LEFT JOIN gl_Train_Progre ss ON
gl_Train_KeyIde as.KeyIdea_ID = gl_Train_Progre ss.KeyIdea_ID
WHERE (((gl_Train_Pro gress.KeyIdea_I D) Is Null) AND
((gl_Train_KeyI deas.Unit_ID)=1 ));

What I seem to be having trouble with is specifying the User_ID in
table 2. I need to specify the current user for example: an sql with a
User_ID = 6 would return KeyIdea_ID of 1, 2, 3, and 4.

Any idea's?

Jul 19 '05 #1
2 1279
I figured it out.

I used the following sql

SELECT gl_Train_KeyIde as.KeyIdea_ID
FROM gl_Train_KeyIde as
LEFT JOIN gl_Train_Progre ss
ON gl_Train_KeyIde as.KeyIdea_ID = gl_Train_Progre ss.KeyIdea_ID
AND gl_Train_Progre ss.User_ID = 6
WHERE (((gl_Train_Pro gress.KeyIdea_I D) Is Null) AND
((gl_Train_KeyI deas.Unit_ID)=1 ));

On Mon, 05 Apr 2004 18:35:35 GMT, ms***@rcsys.net (Greg Gillis) wrote:
I need some help. Here is the problem.

Table_1 (gl_Train_KeyId eas)

+----------------------+----------------+-------------------+---------------+
| KeyIdea_ID | Unit_ID | Group_ID | Title |
+----------------------+----------------+-------------------+---------------+
| 1 | 1 | 27 | yada 1 |
| | | | |
| 2 | 1 | 27 | yada 2 |
| | | | |
| 3 | 1 | 27 | yada 3 |
| | | | |
| 4 | 1 | 27 | yada 4 |
| | | | |
+----------------------+----------------+-------------------+----------------+

Table_2 (gl_Train_Progr ess)

+----------------------+----------------+----------------------+
| ID | User_ID | KeyIdea_ID |
+----------------------+----------------+----------------------+
| 12 | 5 | 3 |
| | | |
| 11 | 5 | 2 |
| | | |
| 10 | 5 | 1 |
| | | |
+----------------------+----------------+-----------------------+
The following sql returns field KeyIdea_ID = 4 which is the only
KeyIdea not in both tables.

SELECT gl_Train_KeyIde as.KeyIdea_ID
FROM gl_Train_KeyIde as LEFT JOIN gl_Train_Progre ss ON
gl_Train_KeyId eas.KeyIdea_ID = gl_Train_Progre ss.KeyIdea_ID
WHERE (((gl_Train_Pro gress.KeyIdea_I D) Is Null) AND
((gl_Train_Key Ideas.Unit_ID)= 1));

What I seem to be having trouble with is specifying the User_ID in
table 2. I need to specify the current user for example: an sql with a
User_ID = 6 would return KeyIdea_ID of 1, 2, 3, and 4.

Any idea's?


Jul 19 '05 #2
I figured it out.

I used the following sql

SELECT gl_Train_KeyIde as.KeyIdea_ID
FROM gl_Train_KeyIde as
LEFT JOIN gl_Train_Progre ss
ON gl_Train_KeyIde as.KeyIdea_ID = gl_Train_Progre ss.KeyIdea_ID
AND gl_Train_Progre ss.User_ID = 6
WHERE (((gl_Train_Pro gress.KeyIdea_I D) Is Null) AND
((gl_Train_KeyI deas.Unit_ID)=1 ));

On Mon, 05 Apr 2004 18:35:35 GMT, ms***@rcsys.net (Greg Gillis) wrote:
I need some help. Here is the problem.

Table_1 (gl_Train_KeyId eas)

+----------------------+----------------+-------------------+---------------+
| KeyIdea_ID | Unit_ID | Group_ID | Title |
+----------------------+----------------+-------------------+---------------+
| 1 | 1 | 27 | yada 1 |
| | | | |
| 2 | 1 | 27 | yada 2 |
| | | | |
| 3 | 1 | 27 | yada 3 |
| | | | |
| 4 | 1 | 27 | yada 4 |
| | | | |
+----------------------+----------------+-------------------+----------------+

Table_2 (gl_Train_Progr ess)

+----------------------+----------------+----------------------+
| ID | User_ID | KeyIdea_ID |
+----------------------+----------------+----------------------+
| 12 | 5 | 3 |
| | | |
| 11 | 5 | 2 |
| | | |
| 10 | 5 | 1 |
| | | |
+----------------------+----------------+-----------------------+
The following sql returns field KeyIdea_ID = 4 which is the only
KeyIdea not in both tables.

SELECT gl_Train_KeyIde as.KeyIdea_ID
FROM gl_Train_KeyIde as LEFT JOIN gl_Train_Progre ss ON
gl_Train_KeyId eas.KeyIdea_ID = gl_Train_Progre ss.KeyIdea_ID
WHERE (((gl_Train_Pro gress.KeyIdea_I D) Is Null) AND
((gl_Train_Key Ideas.Unit_ID)= 1));

What I seem to be having trouble with is specifying the User_ID in
table 2. I need to specify the current user for example: an sql with a
User_ID = 6 would return KeyIdea_ID of 1, 2, 3, and 4.

Any idea's?


Jul 19 '05 #3

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

Similar topics

0
968
by: Greg Gillis | last post by:
I need some help. Here is the problem. Table_1 (gl_Train_KeyIdeas) +----------------------+----------------+-------------------+---------------+ | KeyIdea_ID | Unit_ID | Group_ID | Title | +----------------------+----------------+-------------------+---------------+ | 1 | 1 | 27 | yada 1 | | | | | ...
2
1457
by: David Richards | last post by:
Hi, I'm having a problem linking 4 tables in MYSQL. The first table contains customer details, the next item details and the next 2 contain sales information. The final output of the query should be:-
3
6409
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
2
908
by: Keith | last post by:
I am having a problem creating a many-to-many-to-many type relationship. It works fine, but when I create a view to query it and test it, it does not generate the results I expected. Below if the DDL for the tables and the SQL for the view.
5
1628
by: Ciar?n | last post by:
I have about 7 tables I need to join, but am having a lot of difficulty with the joins, that I need some help on. I'll provide the details of four tables to illustrate the scenario. I have one table called Product, which contains a complete list of products. I have another table called Date, which contains a complete list of dates. I have a table called sales, which contains Product, date and Qty.
7
31548
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.")
0
1318
by: hotgazpacho | last post by:
I have a query where I need to join several tables, one of which is variable (otherwise I'd just hand-code the query). The main table is called media, and has fields common to all media in my application (like project_id, description, comments, etc). I have another couple of tables, one provides a listing of keywords, and another maps keywords to media. I want to enable a search of media by keyword, allowing for multiple keywords. For a...
6
2406
by: Jeff Kowalczyk | last post by:
I need to adapt this an update statement to a general form that will iterate over multiple orderids for a given customerinvoiceid. My first concern is a form that will work for a given orderid, then an expanded version that will work on all orderids with a specific customerinvoiceid as a parameter. I'm sure appropriate joins will handle it, but I'm not making any headway, everything comes back with multiple tuple selected for update...
9
2039
by: jardar.maatje | last post by:
I am logging scientific data. For this a normal relationship database is not idéal but I am going to try it. I have basically three tables like: datarecord: * idx - integer * time - datetime * type - integer
8
6565
by: Dip | last post by:
Hello Experts, Here is the code to flatten a PC hierarchy into a level based table. It works fine. SELECT t1.TASK_ID AS TASK_LV1, t2.TASK_ID AS TASK_LV2, t3.TASK_ID AS TASK_LV3, t4.TASK_ID AS TASK_LV4, t5.TASK_ID AS TASK_LV5 FROM dbo.Project t1 LEFT OUTER JOIN
0
7942
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
8433
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
8429
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...
0
8300
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...
1
5963
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 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...
0
5461
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
3969
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2443
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
0
1287
bsmnconsultancy
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...

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.