473,680 Members | 3,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a single row from two

!NoItAll
297 Contributor
I have an SQL Query that works very well with one exception... (I guess you could say it doesn't work THAT well). I have it retrieving the information I need, but the data comes back in TWO rows and I need it in one.
Here is my query:
Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2.     AssignmentLink.ItemType,
  3.     AssignmentLink.UH,
  4.     AssignmentLink.ItemUH,
  5.     AssignmentLink.AssignmentUH,
  6.     Assignment.UH,
  7.     Assignment.Slug,
  8.     Assignment.StartTime,
  9.     Assignment.Location,
  10.     Assignment.Comments,
  11.     Assignment.Format,
  12.         [User].UH,
  13.     [User].UserName
  14.   FROM 
  15.     [User],
  16.     AssignmentLink,
  17.     Assignment
  18.   WHERE
  19.     AssignmentLink.AssignmentUH = Assignment.UH
  20.   AND
  21.     [User].UH = AssignmentLink.ItemUH
  22.   AND
  23.     Assignment.Slug='CHILD SCARE'
  24.  
The "Child Scare" slug is unimportant, that was for debugging purposes. There is only ONE record in the system (comprised of two rows returned) with Slug='CHILD SCARE'
All of the data I need in the two rows are identical except two fields. The fields are ItemType and UserName.
Can I format the query to return the ItemType and UserName fields from two matching records in a single row?
Oct 11 '16 #1
1 1270
Seth Schrock
2,965 Recognized Expert Specialist
Somewhere you have a many-to-one relationship and one of the tables has two records matching the criteria. Without seeing your data and knowing exactly what you want done, I can't be very specific, but what I normally do is to use subqueries to get the values I need as different fields instead of different records. For example, if an assignmentlink record is related to two different assignments, then you would create two subqueries. The first subquery would get the first record and the second subquery would get the second record. You can then display the data all in one record, even though it is coming from two different records.
Oct 18 '16 #2

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

Similar topics

1
1834
by: Satchidanand Haridas | last post by:
Hi, I have created an application using python/wxPython and py2exe. I have associated a certain file extension with this application so that when I double-click the file, my application is launched. The application runs fine except that a new instance is created when I double click on two different files. Is there a way in which I can make sure only one instance is created? Any additional files are opened in the same running instance?...
3
2391
by: serge | last post by:
I have all the scrips to create a database. I have a few questions: 1- I am creating a batch file that it will call many lines like: db2 -td@ -f filename.sql -z output.txt The order i am using is: 1- Create the database 2- Tables 3- Insert the data
2
2224
by: Andrea | last post by:
I'm having some difficulty creating a report in Access and I need some suggestions. My company issues "Return Authorizations" when customers need to return products. A customer calls in and we provide the number. The customer then returns items for a refund or for an exchange. Here is the basic set up of the tables in question. -ReturnAuthorizationTable- ReturnNumber_PK CustomerID ReturnType
8
5962
by: Nanda | last post by:
hi, I am trying to generate parameters for the updatecommand at runtime. this.oleDbDeleteCommand1.CommandText=cmdtext; this.oleDbDeleteCommand1.Connection =this.oleDbConnection1; this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ApplicantName", dataset.Tables.Columns.DataType, 50,
3
3510
by: Bill | last post by:
I have a seating chart web form that has over 50 entry field controls (tables/booths) where I use a DropDownList box to select a single company name from a single large list of organizations (200 plus conference attendees). All web form datavalues will be one of the same 200 organizations in this list. I would like to avoid creating 50 separate exact copies of the same DataSet object. Can you help? Q. Exactly how do I use the same...
4
1611
by: Cal | last post by:
The Help examples for creating a Registry subkey uses double backslashes between subkeys. The examples for creating a folder use a single backslash. First: Am I right in that double backslashes are indeed needed with Registry methods? Second:Am I right in that single backslashes are indeed needed with folder descriptions?
13
4268
by: Kevin Walzer | last post by:
Which of the Windows/Unix package builders for Python applications is capable of creating single-file executables? I'm thinking of: 1. py2exe 2. Mcmillan Installer/PyInstaller 3. cxfreeze The apps I've seen created by py2exe aren't single-file at all, the install folder is full of files besides the main program. I'm looking for a solution that stuffs all libraries, scripts, and the Python
2
2339
by: ice8595 | last post by:
Hi there, I'm having a little trouble getting this, so please excuse me if my question and description sounds confusing or juvenile. I'm creating a new class called 'Rec'. And essentially I want to reuse the same instance object (myInstance) every time. So it would be created the first time i initiate the constructor, but the following times it would just refer back to the same one. //the specification class Rec {
3
1367
by: dponce | last post by:
Hello, I need some help, this is what I am trying to accomplish. I have 14 different tables, all the tables have the same colums but different information is recorded in each one. What I am trying to do is set up a query to run a report that will give me the total from all 14 tables and just show on one report. Instead of me going into each individual report per table. Thx in advance...
0
198
by: oyster | last post by:
you can try jungle ( http://www.suda-chen.biz/?page_id=21 ) also
0
8912
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...
1
8734
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,...
0
8763
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...
0
7565
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5783
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
4296
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...
0
4505
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2183
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1913
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.