473,395 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Multiple joins between 2 tables and profiles with multiple users

I am trying to make multiple joins between two tables and am at a loss. I've tried a variety of things with this being the latest, but it pulls all records multiple times.

Basically I have a main table of profiles that have several descriptors that are referenced with a SQL ID that is in a DropDown table.

Expand|Select|Wrap|Line Numbers
  1. Table Profile
  2. profiletype (SQL ID)
  3. phoneprovider (SQL ID)
  4.  
  5. Table DropDowns
  6. ID
  7. name
  8. ddvalue
The SQL ID for the different things in the Profile match the IDs in the DropDowns table (For example profiletype ID in the Profile table would be 37 and in the DropDowns table 37 as an ID is a profiletype and the ddvalue is "member". I want to be able to join the tables and have it display the ddvalue not the ID and I have multiple fields like this in the Profile table)

To further add to this mix...I have a table of Users that have the Profile ID attached to them. So you can have multiple users attached to each profile. And then I have drop downs inside the Users table I want to reference like described above.

Here is the query I have gotten to work with 1 DropDown join:

Expand|Select|Wrap|Line Numbers
  1. <cfquery name="newusers" datasource="#application.dsn#">
  2.         SELECT Profile.ID, Profile.username, DropDowns.ddvalue2 
  3.      FROM Profile
  4.      JOIN DropDowns
  5.          ON Profile.profiletype =  DropDowns.ID
  6. </cfquery>
The problem I'm having is when I try to reference more than one DropDown relationship.

Expand|Select|Wrap|Line Numbers
  1. <cfquery name="oneuser" datasource="#application.dsn#">
  2.     SELECT Profile.*, DDprofiletype.ddvalue2 AS d1, DDphoneprov.ddvalue AS d2
  3.     FROM Profile
  4.     JOIN DropDowns DDprofiletype ON Profile.profiletype = DDprofiletype.ID
  5.     JOIN DropDowns DDphoneprov ON Profile.phoneprov = DDphoneprov.ID
  6.     ORDER BY Profile.username
  7. </cfquery>
And I'm trying to list the Profiles with their respective users here, but it isn't working right either.

Expand|Select|Wrap|Line Numbers
  1. <cfquery name="allusers" datasource="#application.dsn#">
  2.      SELECT Profile.ID, Profile.username, Profile.profiletype, Profile.barcode,  Users.fname, Users.lname, DropDowns.ddvalue2, Profile.avatar
  3.      FROM Profile
  4.      JOIN DropDowns
  5.         ON Profile.profiletype = DropDowns.ID
  6.      RIGHT OUTER JOIN Users
  7.         ON Profile.ID = Users.profile_ID
  8.      ORDER BY Profile.username
  9. </cfquery>
May 11 '10 #1
0 1706

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

Similar topics

3
by: Ron Nolan | last post by:
I have a large application that contains lots and lots of financial history data. The history data is currently set up in a table called 'TblHist' that exists inside each of these three .mdb...
6
by: Don Leverton | last post by:
Hi All, I've got a situation where I am developing an Access 97 app for a client, and am in the "beta testing" stage. I have split the app up, using the DB splitter, into front-end /back-end...
1
by: Felix_WafyTech | last post by:
Hi, I'm working with the ObjectDatasource and the application is getting more and more chatty. Is there a way I could make the ObjectDatasource support multiple DataTables that could be...
4
by: HLCruz via AccessMonster.com | last post by:
I am working with a database that has client information separated in to 4 related tables - tFolder, tAddress, tEmail, tPhone number. In addition there are related tables tGifts and tCalls. The...
5
by: rewalk | last post by:
Hello all, I've set up protected Excel sheets that users can paste data into. I then need to be able to pull the data they paste into multiple access tables and then reset the Excel spreadsheet...
2
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...
2
by: beargrease | last post by:
I'm kind of comfortable with basic joins, but a current project requires a complex query of many tables. The GROUP_CONCAT(DISTINCT ...) function has been very useful as returning my values as comma...
3
by: modernshoggoth | last post by:
G'day all, I'm trying to update a single table (containing plans for flights) with information from the same and other tables (containing info for organisations and locations). tblFlightPlans...
3
by: John Roberts | last post by:
Hi, Is it possible to access a tables data over multiple joins? For instance, for each row of Table A, I want the associated data from Table D. Is this possible in access? If it's not, could you...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
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
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,...

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.