Many to Many - display query result?

Greetings
In a help desk app, the manager can assingn more than one technician to a project.
Whe he or she assigns a project, the tech ID & project ID are inserted in a junction table. This works fine.
The description, assigned date & due date field are static- the resolution (textarea) needs to be added to as the project progesses, as well as hours spent by each tech.
I am running into problems displaying what the technician sees on their "contol panel".
When the tech views the details of an ongoing project, I am getting cartesian product results.
The tech needs to add to the resolution (textarea),  view who else is working on the project, and how many hours each has contributed.
The project display page query:
SELECT DISTINCT project_ID, project_num, project_desc, project_res, assign_date, assign_time, due_date, complete_dte, complete_time, assigned,
tech_1_hours, tech_2_hours, tech_3_hours, tech_4_hours, tech_ID, junc_tech_ID, junc_project_ID
FROM main_projects, lookup_tech, junction_project_tech
WHERE tech_ID = #Session.user_id#
AND project_ID = #URL.project_ID#
AND project_ID = junc_project_ID
AND tech_ID = junc_tech_ID
And the math;
<cfset 'total' = (#tech_1_hours#+#tech_2_hours#+#tech_3_hours#+#tech_4_hours#)>
The project display repeats itself for every technicain-
Any help with this would be greatly apprecaited.
24 month to retirement!
Norman

Hi,
Will all Students have exactly two Teachers?
If not picture your sample with two more Students.
One having 1 Teacher
One having N Teachers
Think about N, what will it be? - How would you create a table with N columns?
If you can't easily answer above, re-consider what you are trying.
That said, it could still be done - even if all Students do not have exactly two Teachers - and is called Pivot a dynamic number of columns.
Examples are in FAQ
SQL and PL/SQL FAQ
Still a bad idea, with or without known number of teachers
Regards
Peter

Similar Messages

  • How to display query result in seperated page.

    How to display query result in seperated page, if the results are very big (more than 5000 records) and there are so many concurrent users (about 500 - 1000 users).
    Are there any solutions or frameworks?
    Plese help me .........
    thanks,
    --bhasin

    Hi,
    How to display query result in seperated page?I think RowSet will be the better technology to use in this
    situation.For more information on this please visit http://developer.java.sun.com/developer/Books/JDBCTutorial/chapter5.html
    which explains in detail about RowSets.
    Hope this helps.
    Good Luck.
    Gayam.Srinivasa Reddy
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support/

  • Problem Displaying Query Result

    I have been working through David's book 'Dreamweaver CS5 Training from the Source' and am attempting to adapt the tutorials for my own ideas.
    My problem, I believe is in displaying the results of a database query. I want to display to the user a list of group names they are associated with.
    The query looks like this:
    $id = "$identity->user_id"; //logged in user
    $sql = mysql_query("SELECT name
                                   FROM groups
                                   INNER JOIN user2group USING (group_id) // reference table contains user_id and group_id
                                   WHERE user_id = $id
                                   ORDER BY name")or trigger_error ( mysql_error ( ) );
    while($row = mysql_fetch_array($sql)){
              $groups = $row['name'];
    I attempt to display the results with:
    <?php echo "$groups"; ?>
    I have also tried:
    $sql = mysql_query("SELECT name
                                   FROM groups
                                   INNER JOIN user2group USING (group_id) // reference table contains user_id and group_id
                                   WHERE user_id = $id
                                   ORDER BY name")or trigger_error ( mysql_error ( ) );
    while($row = mysql_fetch_array($sql)){
              $groups = array();
              $groups[] = $row['name'];
    and display with:
    <?php echo implode('<br />', $groups); ?>
    In both scenarios I get only one record displayed. (there is more than one record). The records seem to be available to display because if I change the ORDER command I get a different result.
    Any help is much appreciated.
    Thank you

    Thank you so much for the explanation of the while loop it was extremely helpful. I was able to get my results to display correctly by including the echo statement in the while loop.
    I spent several hours trying to use the array_push command with no success. I did explore the link you provided, but found many of the examples people gave to be very complicated. I would really like to start working with this command, if you would be able to provide me with an example based on my query and I can see it working I can start varying it to some of the more complicated methods given in the link.
    Thank you again for your help.

  • 2.1 EA2 does not display query results, query works fine in sqlplus

    2.1 EA2/Windows XP 32-bit
    The following query does not show any results for Total(GB) and Free(GB) columns. The diskgroup name shows correctly.
    SELECT
    DG.name ,
    ROUND(SUM(DSK.TOTAL_MB)/1024,2) "Total (GB)",
    round(SUM(DSK.FREE_MB)/1024,2) "Free (GB)"
    FROM
    V$ASM_DISK DSK,
    V$ASM_DISKGROUP DG
    WHERE
    DSK.GROUP_NUMBER=DG.GROUP_NUMBER
    group by DG.name;
    The query works fine when run from SQL*Plus:
    SQL> SELECT
    2 DG.name ,
    3 ROUND(SUM(DSK.TOTAL_MB)/1024,2) "Total (GB)",
    4 round(SUM(DSK.FREE_MB)/1024,2) "Free (GB)"
    5 FROM
    6 V$ASM_DISK DSK,
    7 V$ASM_DISKGROUP DG
    8 WHERE
    9 DSK.GROUP_NUMBER=DG.GROUP_NUMBER
    10 GROUP BY DG.name;
    NAME Total (GB) Free (GB)
    DG1 707.98 162.32
    DG2 134.84 122.68
    SQL>
    This must be something unique to SQLDeveloper. I tested in 2.1 EA1 and 1.5.5.59.69 and the query does not show results for the Total (GB) and Free (GB) columns.

    I would like to update the problem. It seems like when SQLDeveloper is connected to ASM instance, it has trouble using the divide operator (/). For example, the following query works fine:
    SELECT
    name,
    TOTAL_MB
    FROM
    V$ASM_DISKGROUP;
    But if I try to divide the TOTAL_MB by any number, the column shows blank (the column is blank, not NULL). So, if I try to run the following query, the output will just display diskgroup names. The TOTAL_MB/1024 column shows blank.
    SELECT
    name,
    TOTAL_MB/1024
    FROM
    V$ASM_DISKGROUP;
    If I run the same query in SQL*Plus from the same desktop using the same TNS alias, it works just fine which tells me that it is a SQLDeveloper problem.
    When I am connected to a regular database, then the problem does not show up and SQLDeveloper is able to display the results even when I am using the divide operator (/).

  • Create SP that returns value and at the same time displays query result in output window

    I would like create an SP which will return the records from the table and also return value to my c# client application.
    For Example:
    Select * from employee returns all the query results in output window.
    Now I want to create an SP
    Create procedure Test
    As
    Declare @ret int,
    Select * from employee
    set @ret = Select count(*) from employee
    if @ret > 0
    return 1
    else
    return 0
    The above algo should return 1 0r 0 to c# client application and at the same time display all employees in sql query output window.
    Can u pls help in this regard.

    The above algo should return 1 0r 0 to c# client application and at the same time display all employees in sql query output window.
    Why?  and No!
    Why?  Your procedure generates a resultset of some number of rows.  You check the resultset for the presence of rows to determine if "anything is there".  You don't need a separate value to tell you this.  Note that it helps
    to post tsql that is syntactically correct.   While we're at it, if you just need to know that rows exist there is no need to count them since that does more work than required.  Simply test for existence using the appropriately-named function
    "exists".  E.g., if exists (select * from dbo.employee). 
    No!  A stored procedure does not display anything anywhere.  The application which executes the procedures is responsible for the consumption of the resultset; it chooses what to do and what to display. 
    Lastly, do not get into the lazy habit of using the asterisk in your tsql code.  That is not best practice.  Along with that, you should also get into the following best practice habits:
    schema-qualify your objects (i.e., dbo.employee)
    terminate every statement - it will eventually be required.

  • How to display query result like this

    I got a query...gives list of names.
    i want to display
    11.  Peter
    12. Jessica
    32. Leo
    15. Jamie
    36. Edward
    how i get static number infront of my query result.
    static number is not in order.

    Amm85 wrote:
    I got a query...gives list of names.
    i want to display
    11.  Peter
    12. Jessica
    32. Leo
    15. Jamie
    36. Edward
    how i get static number infront of my query result.
    static number is not in order.
    You could use the function queryAddColumn to add the numbers as a separate column to the query.
    Let us suppose the name of the query is "myQuery". Then you could proceed as follows
    <!---Define your "static" list of numbers --->
    <cfset staticList = "11,12,32,15,36,13,23,14,33,16,44,31,17,34,18">
    <!--- Create an array from the static list. --->
    <cfset staticNrArray = ArrayNew(1)>
    <cfset staticNrArray = listToArray(staticList)>
    <!--- Add the array as a column to the query. --->
    <cfset nColumnNumber = QueryAddColumn(myQuery, "staticNr", "integer", staticNrArray)>
    <!--- Verify whether it works as expected--->
    <cfdump var="#myQuery#">
    The list I have given here has 15 numbers. This will naturally instruct ColdFusion to add a new column named staticNr, having 15 rows. You might like to know that the queryAddColumn function enables padding.
    Here is how it works. Suppose that the query originally had only 8 rows before you added the column(of 15 rows). Then, in the new query, ColdFusion would pad the last 7 rows of the other columns with null values. If the original query  had 20 rows instead, then Coldfusion would pad the last 5 rows corresponding to the staticNr-column with null values.

  • Trying to display query results in 2 columns

    I am trying modify someone elses existing code to display the
    results of a query in 2 columns on a web page.
    The result of the existing code can be seen
    here
    Below is the code that I am trying to modify
    <table width="95%" border="0" align="center"
    cellpadding="4" cellspacing="2">
    <cfoutput query="News" startrow="#StartRow_News#"
    maxrows="#MaxRows_News#">
    <tr align="center" class="TEXTnormal">
    <td nowrap class="TEXTnormal
    style1">................................................................................. ...................................</td>
    </tr>
    <tr class="TEXTnormal">
    <td><table width="100%" border="0" cellpadding="0"
    cellspacing="0" class="TEXTnormal">
    <tr>
    <td><cfif News.ImageNameThumb gt 0>
    <a href="news_view.cfm?recordID=#News.ID#"><img
    src="uploadedimages/#News.ImageNameThumb#"
    alt="#News.ImageCaption#" hspace="8" vspace="0" border="0"
    align="left"></a>
    <cfelse>
    </cfif></td>
    <td><a href="news_view.cfm?recordID=#News.ID#"
    class="TEXThighlight">#News.Title#</a> -
    #News.Day#.#News.Month#.#News.Year# <br>
    #News.Summary#</td>
    </tr>
    </table></td>
    </tr>
    </cfoutput>
    </table>
    I have changed the above code to
    <table width="95%" border="0" align="center"
    cellpadding="4" cellspacing="2">
    <cfset LoopEndRow = CEILING(#EndRow_News#/2)>
    <cfloop
    index = "row"
    from = "#StartRow_News#"
    to = "#LoopEndRow#"
    step = "1">
    <tr class="TEXTnormal">
    <cfset breaker = 0>
    <cfloop
    index = "column"
    from = "0"
    to = "2"
    step = "1">
    <cfoutput query="News1" startrow="#StartRow_News#"
    maxrows="#MaxRows_News#">
    <td width="50%">
    <table width="100%" border="0" cellpadding="0"
    cellspacing="0" class="TEXTnormal">
    <tr>
    <td><cfif News1.ImageNameThumb gt 0>
    <a href="news_view.cfm?recordID=#News1.ID#"><img
    src="uploadedimages/#News1.ImageNameThumb#"
    alt="#News1.ImageCaption#" hspace="8" vspace="0" border="0"
    align="left"></a>
    <cfelse>
    </cfif></td>
    <td><a href="news_view.cfm?recordID=#News1.ID#"
    class="TEXThighlight">#News1.Title#</a> -
    #News1.Day#.#News1.Month#.#News1.Year# <br>
    #News1.Summary#</td>
    </tr>
    </table></td>
    <cfset breaker = breaker+1>
    <cfif breaker EQUAL 2>
    <cfbreak>
    </cfif>
    </cfoutput>
    </cfloop>
    </tr>
    </cfloop>
    </table>
    The results of this modified code can be see
    Here
    as you can see what I have done gives the correct number of
    columns (2)
    and the correct number of rows for the quantity of data (3)
    however each row shows only the first 2 pieces of data
    returned by the query
    Can I modify the query output so that it returns pieces of
    data off set by the amount of data already output?
    if so how?

    Right off the bat, you have 2 loops and I cant see why...
    So what is happening, is the outer loop is going 3 times...
    for 3 rows, then your inside loop is showing the first record, the
    Breaker var is breakign out of this loop after one row is shown.
    Then the main loop says do it again...
    You don't need nested loops to accomplish this, I dont
    understand why you would think of needing that...
    Looking at your code, just get rid of the outer loop... there
    is no need for it. You are already looping around the query object
    in the inner loop, thats all you need...
    Heres some psudeo code to help you out...
    loop around query maximum of 6 rows
    -- display data
    -- if recordcount EQ 2 or recordcount EQ 4 then
    ----- </tr><tr> <!--- this will make the new
    row --->
    end loop

  • Display Query results in excel on the Web

    Hello,
    I am trying to display data from a query in excel on the web without creating an actual file. I know that I can create a CSV file using UTL_FILE and display it but I was hoping there was a way to do it without actually creating the file. I have a procedure that looks similar to
    PROCEDURE displayAsCSV is
    cursor STUD_CURS is
    select * from students;
    BEGIN
    for STUD_REC in STUD_CURS loop
    htp.print(' " '||STUD_REC.FIRST_NAME||' " , " '||STUD_REC.LAST_NAME||' " ');
    end loop;
    END;
    Does anyone know if it is possible to display these results in excel in the browser by altering the MIME types or something similar?
    Thanks

    Check Tom's owa_sylk utility together with the appropriate mime-type.

  • Displaying Query Results as Hyperlinks using PHP

    I have a table returning a query, one of the fields returns
    an email address. I want to link this so the admin user can click
    on it and have his or her email client open to that address. The
    address does not go in the DB as a link. Here is the code:
    .$row[4]. being the returned value, I tried adding a <a
    href='mailto:'> the value</a> several different ways but
    it just breaks the page. any insight?
    Thanks,
    Steve

    steevo2 wrote:
    > Thanks, it didn't work , but got me going in the right
    direction. double
    > quotes will not work inside any tag
    Complete nonsense. The reason it didn't work is because I
    missed out a
    single quote. The correct code is this:
    echo '<td width="175"><a
    href="mailto:'.$row[4].'">'.$row[4].'</a></td>';
    Note the extra single quote after the first $row[4].
    > Double quotes do work outside of tags, I have them
    surrounding the rest of my
    > table tag elements, but single quotes work in that
    respect as well.Thanks for
    > responding, plan on getting your books soon.
    If you get one of my books, you'll find a detailed discussion
    of the
    difference between single and double quotes, and how to mix
    them. It's a
    subject that confuses many beginners. And, as my mistake
    shows, it
    catches out more experienced people too. The difference
    between a
    beginner and a more experienced developer is that the latter
    can spot
    more quickly where the error lies.
    > I must confess, pulling this off
    > in CF is much easier. But hey, open source is free. I
    use CF at work and PHP at
    > home.
    Personally, I don't find CF easier, but I'm sure it's more a
    question of
    what you're used to, rather than one being "easier" than the
    other.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • How to Display Query Results in a Max Width Formatted Way?

    Hi,
    I want to run a query to show the columns within headers to be formatted in a way that looks equal in width. I just want to get the max width for each column and display each item in a max width format in a query. Thanks.
    Ex.
    First Name Last Name City
    John Sumi New York
    Jay Heely Texas

    if you are spooling a file on sql*plus use the column formatting method.
    syntax:
      COL <column_name> FORMAT a<integer>example:
      COL emp_name FORMAT a40

  • How to display query results in windows side by side in Access 2010

    In Access 2010 - when I open a query the result is desplayed in a tab.
    When I open a new query - a new tab is created - now in front of the other tab.
    I would like to see both queries at the same time.
    How is that done?

    Select File > Options.
    Click 'Current Database' in the navigation pane on the left.
    Under 'Document window options', select 'Overlapping Windows'.
    Click OK, then close and reopen the database.
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Display Query Results.

    I access a Database and retrieve a CLOB containing the XML Data. Using the XML Parser for Java V2 I am able to retrieve the element names only but I am unable to retrieve the contents.
    i.e. suppose the markup is <name>Rathnar</name>, I am able to access the name but not the value Rathnar.
    Please help.

    Try dumping out the tree with a print method.
    Need some sample coding to provide further info.

  • Warning pop up before query results display

    Hi,
    Iam getting one pop up Box before query results display  in that box I am getting around 10 messages like below.
                 *Warning  period 00000000- No vaild translation date to specify (ZMRATECMN)"
       after I click on the CLOSE tab on that box it is displaying query results.
      It seems this is warning related to currency traslation.
      How to avoid this pop up box display with the messages.Please help me.

    Hi,
    You can supress the messages in RSRT. Select your query and click the button warnings button in toolbar. There you can see all the messages. select the check boxes of the corresponding messages you want to supress and click save.
    Thanks
    Venkat

  • Displaying SQL Query results in rows instead of Columns

    Hi,
    I'm fairly new to Oracle so forgive me if this is a really stupid question.
    I used Mysql for a while and if I wanted to display query results in rows instead of columns I could end the SQL command with '\G' instead of a semicolon.
    This would give me output like...
    Column_1: AAAA
    Column_2: BBBB
    Column_3: CCCC
    Instead of the normal
    Column_1 Column_2 Column_3
    AAAAAA BBBBBBB CCCCCCC
    Is there an equivalent in SQLPlus to the MySQL \G termination?
    Thanks.
    John

    > so forgive me if this is a really stupid question.
    It is certainly not a stupid question, but pivoting is a very frequently asked and answered question:
    [url http://forums.oracle.com/forums/search.jspa?threadID=&q=pivot&objID=f75&dateRange=all&userID=&numResults=15]http://forums.oracle.com/forums/search.jspa?threadID=&q=pivot&objID=f75&dateRange=all&userID=&numResults=15
    In 11g you have special PIVOT and UNPIVOT functions.
    Regards,
    Rob.

  • SSMS Addin - How To Access Query Results Grid

    Hi,
    I want to access Query Result Grid(Results) in SSMS addin but I did'nt found anything.
    How can I access Query Result Grid, Rows, Columns and Cells when I executed a script?
    Thanks.

    SQL Server Management Studio currently supports query execution results to be displayed in three different ways: Results to Grid,
    Results to Text and Results to File.
    By default SQL Server Management Studio is configured to display query results in
    Grid format.  If you want to change the default to some other option follow these steps.
    1. In SQL Server Management Studio, under Tools menu, click
    Options as shown in the snippet below.
    2. In the Options dialog box, expand Query Results, expand
    SQL Server and then select General as shown in the snippet below. In the right side panel choose one of the three options shown below in the
    Default Destination for results drop down list and click
    OK to save the changes as shown in the snippet below. The changes will go into effect once you open a New Query window.
    Query Result Options for Results to Text
    In this format you have the option to display the results in a different tab as well as setting different output options.
    In the Options dialog box, expand Query Results, expand
    SQL Server and then select Results to Text tab as shown in the snippet below. In the right side panel first select the checkbox for
    Display results in a separate tab and then select the checkbox for
    Switch to results tab after the query executes and then click
    OK. If you would like to also display the column name in the result set then choose the option Include column headers in the result set
    as shown in the snippet below.
    The options you can use in the Text format are:
    Output format: - In the above snippet you could see that by default the output is displayed as columns aligned. Some of the other options that are available are Comma Delimited,
    Tab Delimited, Space Delimited and Custom Delimited. If you choose the Custom Delimited option in the Output format drop down list then you need to specify a character of your choice for the delimiter in the
    Custom delimiter text box.
    Include column headers when copying or saving the results: - If this option is selected, then whenever the results are copied to clipboard or it is saved to a file the column headers are also copied along with the results.
    Include the query in the result set: - The text of the query is displayed as part of query output under the messages tab.
    Scroll as results are received: - If this option is selected, then the display focuses on the most recently returned records at the end of the results set.
    Right align numeric values: - If this option is selected, then numeric values will be aligned to the right of the column.
    Discard results after query executes: - If this option is selected, then the query results are not displayed in the reviewing pane.
    Display results in a separate tab: - If this option is selected, then the result set after query execution will be displayed in a new tab instead of at the bottom of the query window.
    Switch to results tab after the query executes: - If this option is selected, then after the query execution the screen focus will be set to the results tab.
    Maximum number of characters displayed in each column: - This sets the maximum characters to display for any one column.  So if you have a column that is 500 characters this will only show the first 256 if you keep the default setting.
    Ref link :http://www.mssqltips.com/sqlservertip/2346/different-options-for-query-results-in-sql-server-management-studio/
    Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/

Maybe you are looking for

  • Java.io.File.delete worked in 1.1, 1.2, 1.3 & 1.4, but not in 5.0

    I have a logging utility I wrote originally in Java 1.0. A nightly housekeeping task runs which creates a ZIP file for the previous days log, then deletes the .log file. If I run this software with Java 5.0, the File.delete fails and the .LOG file re

  • Create a Service for ESS if standard service is not available

    Hi Folks, How can I create a link in resources if standart resources are not available in ESS? Thanks!

  • Store order updating?

    The "order" section of apple store is offline, as in updating, is apple preparing shipments of whole heap of orders this week? in my case sunday is the new week lol. The wait for the MBP with retina display

  • 775MB Illustrator file causes Illustrator to stop responding...

    I was working on a file this morning and saved it in .Ai format. This afternoon I came back to work on it again and now it won't open. Illustrator hangs, and then stops responding. Is there a way I can fix this?

  • Update a date column

    Hello hello, I just want to update a column with a specific date. update table set date = ... I almost tried everything. Also to_char and to-date and I always get the following error Message: ORA-01747: invalid user.table.column, table.column, or col