Combining result of three queries to form a single table

Hi ..
I have three select queries. Each of them returns a single column. I want the result of these queries into a single table..
I tried this way..
select * from
(first select),(second select),(third select);
this gives duplicate rows... Any held would be appreciated

Hi,
Welcome to the forum!
1005370 wrote:
Hi ..
I have three select queries. Each of them returns a single column. I want the result of these queries into a single table..Remember that the people who want to help you don't know as much about your tales and your application as you do; in fact, they might not know anything at all about them.
You might ask a friend: "How can I get to that restaurant we went to last week?", and expect to get a good answer, because your friend knows where you are starting from, and knows, from that brief description, where you want to go. But would you expect a stranger on the internet to answer the exact same question? Of course not! A stranger on the internet wouldn't know where you're starting from, or where you want to go. How could a stranger give you directions with only that information?
SQL code is like directions. A SQL query can tell you how to get a certain result set from a certain sample data set. No matter how well someone knows SQL, they need to know something about the data in a problem and the results needed fom that data before they can start writing a query to get those results from that data.
Whenever you have a question, you need to post a little sample data (CREATE TABLE and INSERT statements) for all tables involved, and the results you want from that data in this case, the contents of the new table).
All this and more is in the forum FAQ {message:id=9360002}. Take a few minutes now to read that page. It can realy help you get better results faster on this forum.
I tried this way..
select * from
(first select),(second select),(third select);
this gives duplicate rows... Any held would be appreciatedIf duplicate rows are the only problem, then just add DISTNCT t the main SELECT clause:
select DISTINCT  *
from    (first select)
,     (second select)
,     (third select)
;However, I'll bet duplicate rows aren't really the problem. It's much more likely that the problem is duplicate values in just 1 column.
Again, how to get the output you want from your data depends on your data and the output you want. Post CREATE TABLE and INSERT statements for some sample data, and the complete results you want from that data. Explain how you get those results from that data.

Similar Messages

  • How to create a master detail form using single table

    Hi,
    how to create a master detail form using single table.
    Regards,
    M. Satish

    Hi
    how to create a master detail form using single table.Make the Master ur pks the details the rest of ur data base field in the detail it's a mater of organizing fields on a form M-Detail...
    Now What ?
    Regards,
    Amatu Allah

  • Sum calculated data results from three queries in another query

    Hello,
      I would like to read calculated data from three different queries and sum them in another query.  Is it possible to do it, please?

    Hi there,
    We have done this in Excel with a debtors report. I have five queries, each on a different sheet in a workbook. I have their total line appearing at the top of the results area.
    Then I have an Excel worksheet with Excel formulas to bring through the totals on the other reports.
    i.e.   +Sheet1!C30      + Sheet2!C35     + Sheet3!D40    = Result
    Hope this helps,
    Regards
    Gill

  • Display combined results of 2 queries in 1 BEx Web Report.

    Dear Experts
    I tried to achieve this in just 1 BEx Query and found it difficult.
    Then I ended up creating 2 BEx Queries getting partial result and then amalgamating both in WAD. Still I think there should be a way to achieve what I need from just 1 BEx Query. Below is what I am trying to achieve:
    Query 1:
    Overall Result is the Total Number of Invoices restricted by 2 values.
    Credit Invoices is the Total Number of Invoices restricted by 1 value.
    % of Credits over Total Invoices = Credit Invoices / Overall Result
    Query 2:
    I have created a Condition on 'Reason Codes' to pick on the Top N (3 in this case) to display the values in %.
    All the CHARs and KEYFs are in the Rows Column only for both the Queries at the moment. When I am trying to amalgamate both into 1 BEx Query, the Query is throwing up errors and Execution is falling over. Another issue here is, there are 3 Reason Codes in the Third Place when I checked in ListCube and don't know what needs to be done. I am planning to discuss this with the Business Users if this should be extended to Top 5 instead of Top 3. Any ideas..!
    Users want to see the final report only in Web Analyzer as they do currently (so BEx Analyzer & Workbook are out of question). But I will be using Web Templates eventually to bring together 8 (it will be 9 if this report can't be done in 1 BEx Query) BEx Reports.
    How can I achieve this in just 1 BEx Query?
    Thanks for your time in advance.
    Kind regards,
    Chandu

    Hi Suman
    Thanks for your reply. When I am having both the parts of Query 1 & Query 2, the BEx Report is falling over when executed pointing to Condition.
    The second Query will pick the Top 3 Reason Codes for a particular Customer and then the individual Document Count for these 3 Reason Codes is divided by the Overall Result (Document Count) to give the individual Result across each row as %.
    Hope this is clear now. I tried Cell Definitions but didn't find it useful in this scenario, or I might be missing something. Can you please explain me in detail of how this can be done in 1 BEx Query using Cell Def?
    Please let me know if this can be achieved in Single BEx Query.
    Thanks,
    Chandu

  • Combining results two LDAP queries or/and LDAP SQL

    Hi,
    Is it possible to combine two ldap query results? Just
    something like the join function in SQL?
    And another question I have if it is possible to combine an
    LDAP an SQL query> (just like you can use JOIN to query in two
    tables, but then use something to do the same with ldap and sql)
    Is there anybody who knows if this is possible?
    Regards

    Can you provide an example of your code and the desired
    result, please? Thanks.
    Chris

  • Microsoft Access 2010 Creating a Form from Multiple Tables

    Hi.
    I am brand new to Microsoft Access and have had some exciting success making forms from single tables. This has made my data entry life much easier. However, I am continually stumped on one form I want to make. I would like to make a form that will let me
    update which brands retailers are selling. Most of this information is in my SalesHx table. However, my SalesHx table only uses RetailerID and BrandID to record history. The Brand's name (linked to a BrandID) is stored in my Brand Table and the Retailer name
    is stored in my Retailer table (linked to a RetailerID). I would like to be able to see the brand's name and the retailer's name when entering in data on a form, since I cannot remember the ids that associate with the names. I have been able to make a form,
    with a subform, that displays all of the information I want to see. When I update this form, though, with a new record, it invariably thinks that I am adding an entirely new record, not simply recording a new sales date for an already known brand. Even if
    I make the brand name a combo box that is limited to the fields on my table, this still happens. I will have BrandX as brand number 100 and as brand number 300 if I add it in through my sales history form. I am ready to throw access out the window. Can anyone
    offer advice?

     When I update this form, though, with a new record, it invariably thinks that I am adding an entirely new record, not
    simply recording a new sales date for an already known brand. 
    In what table is the SalesDate recorded?
    Build a little, test a little

  • How to send three attachments using three queries in a single email using sp_senddbmail

    Hi All,
    I have three scripts for extracting permissions at server,database & object level.Now how do i can execute all three queries and send multiple attachments in a single email using sp_senddbmail.I have done this before for single queries but not multiple
    queries. Kindly suggest.
    Regards
    Rahul

    Hi All,
    The requirement was that i had three different queries for listing permissions at server,database and object level.I wanted to build an solution to email results in attachment to user.
    However i have managed to do this with SSIS Package.I was curious to know if it can be done without SSIS.
    Thanks you all for your time and effort for this.
    Rahul
    It can be done without SSIS
    Just have a procedure to return  three query results as a single resultset. Then use sp_send_dbmail to execute query and send results as a email
    See
    http://blogs.msdn.com/b/sqlagent/archive/2010/11/03/sql-database-mail-send-t-sql-results-by-email.aspx
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Queries executed on generic buffered tables form table structure?!

    Hi,
    generic buffered tables only store parts in the buffer that were queried or rather are queried. Thus the WHERE clause of an SQL stmt defines which parts of a table to store, when a part is read for the first time.
    An example:
    A table has 3 key fields. I execute a first query and parametrize two of the key fields. Now a generic region is loaded into to buffer corresponding to the two parametrized key fields.
    If I execute another query attaching only the first key field within my query, what will happen, if we assume that the key field is parametrized with the same content like in the first query?
    Will there be one big and one smaller region holding the same data like the big one?

    Hi Holger ,
    Queries which donot fully parametrize the generic key will not load / reload the buffer .
    Say Table has 5 Keys, you define generic key as 3.
    Queries which have parametrized 3 or more key will load / reload the buffer  . If you only parametrize 2 keys it will not load the buffer . Different key combinations of first three keys will exist as different generic areas in buffer .
    Check this
    http://help.sap.com//saphelp_470/helpdata/EN/cf/21eab8446011d189700000e8322d00/frameset.htm
    <b>It is also possible that too many accesses will bypass the buffer and go directly to the database, <u>since they do not fully define the generic key of the table</u>.</b>
    Cheers

  • Add results of different queries in a single report.

    Hi guys,
      I have one problem, plz help me out. Actually I have 3 queries in a report. The three queries come out with a single values each. The queries are suppose ZBQ1, ZBQ2 and ZBQ3 in a single report in Report designer, its name is suppose ZREP1. I need to calculate the sum of 3 results of the previous queries. and show it in a particular section in the report. Please help me out.
    Thanks,
    Niloy

    HI
    Better to use the workbook. just create the workbook with these three reports and place the three reports at bottom in the excel sheet then you caluclate the formula based on your requirement and place that results in top of the excel(workbook).
    Regards,
    Chandra.

  • How do I reorder the form results from a non-BC form in Muse?

    I have a problem with Muse, in that the emails that get delivered from filled-in forms have various fields in the wrong order and not the order that the fields appear in the actual form.
    How do I ensure the form results emails maintain the order of the fields in the form?
    For example, on the www.actconstruction.com Subcontractors form, several of the fields are wildly out of order. Here's a screen capture of the form results email:
    Here's the form as it appears on the site. You can see the fields are in completely different order to the results emai:
    So, how do I make sure the fields follow a particular order that I want them to (i.e. in the order I placed them in the form itself)?
    The form can be seen at www.actconstruction.com/contact-us.html. This shows the actual order of information. The form results email should follow the order exactly as shown on the web site.
    I've had complaints from clients about this and need to handle it immediately. Please have someone get back to me with a figure-out.
    Many thanks,
    Len Williams
    727-466-6888

    I have a problem with Muse, in that the emails that get delivered from filled-in forms have various fields in the wrong order and not the order that the fields appear in the actual form.
    How do I ensure the form results emails maintain the order of the fields in the form?
    For example, on the www.actconstruction.com Subcontractors form, several of the fields are wildly out of order. Here's a screen capture of the form results email:
    Here's the form as it appears on the site. You can see the fields are in completely different order to the results emai:
    So, how do I make sure the fields follow a particular order that I want them to (i.e. in the order I placed them in the form itself)?
    The form can be seen at www.actconstruction.com/contact-us.html. This shows the actual order of information. The form results email should follow the order exactly as shown on the web site.
    I've had complaints from clients about this and need to handle it immediately. Please have someone get back to me with a figure-out.
    Many thanks,
    Len Williams
    727-466-6888

  • I am automating the process of sending appointment reminders to my clients. I started with an alert with an email in calendar using the clients email address as a custom entry in my me card in my contacts. this was resulting in three emails being sent wit

    I am automating the process of sending appointment reminders to my clients. I started with an alert with an email in calendar using the clients email address as a custom entry in my me card in my contacts. this was resulting in three emails being sent with slightly different versions of the same address (see my previous post). Heating someone else's suggestion I created a workflow file to send an email and calling that file from an alert on my calendar. This is working and sends only one email to the client.
    My calendar is on I cloud and I access it from three different computers so I can keep my appointment calendar current. The files that send the email only exist on one computer. My other computers show error messages when those emails get sent. It seems that each computer wants to send the email. It's a small problem but is there a way that I could not get those alerts.
    But appreciate any thoughts about this. It seems like both problems might be related to the iCloud system.
    Thank you in advance,
    Michael

    Good work, catch so far Michael, does seem to be a "feature" of iCloud syncing, not sure what you could do to disable it.

  • How do i combine all my three computers

    I CANNOT REMEMBER HOW TO COMBINE ALL MY THREE COMPUTERS. 

    Sorry, I have no idea what you mean.  What do you want to combine about them?
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • How to combine Row members in Create Composit Forms in Planning 9301

    Hi All,
    I'm working on Hyperion System9 Planning 9.3.01. I have created two data forms for Actuals and Budget data. Wherein in Actuals form the actual data is pulled from the Oracle GL and I'm entering the budget data in my Budget Form.
    Now the question here is I wanted to combine these tow forms into a single form using "CreateComposite" option and I'm able to create the composite form for both actual and Budget form. But the composite form displays two separate forms side-by-side. Whereas I wanted to combine the Row members of both forms as both have same row members.
    Any help will be highly appreciated.

    Hi sajid
    There was nothing more description about your issue in this site and I found an issue below is mostly like yours
    http://www.codeproject.com/Questions/855487/how-to-combine-two-table-value-in-rdlc-report
    In the issue above, if you want to show the two other tables in the report, I think you could combine the tables into one datatable joining on key. The link below show an example of a DataSet Helper from Microsoft about combine DataSets. Take note of
    the related content for other DataSet Helper examples. And then you could use the datatable in your RDLC.
    # HOW TO: Implement a DataSet JOIN helper class in Visual C# .NET
    http://support.microsoft.com/kb/326080/en-us
    In an alternative way, I think you could create a view in the database which combine your tables and use it in your rdlc.
    In addition, your issue is about asp.net and you could get more support in the asp.net forum whose link as below.
    http://forums.asp.net
    Best Regards
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • Combine two set of queries

    Hi,Please can any one help me how to combine the following two queries...
    Query 1
    SELECT distinct GCC.segment1,GCC.segment2,GCC.segment3,GCC.segment4,GCC.segment5,
    GCC.segment6, DECODE(gcc.segment6,NULL,'',SUBSTR(apps.gl_flexfields_pkg.get_description_sql( gcc.chart_of_accounts_id,6,gcc.segment6),1,40))
    DETAILS, sum(gje.accounted_dr) BUDGET_2014
    FROM  gl_je_lines gje, gl_code_combinations gcc
    WHERE gje.code_combination_id(+)=gcc.code_combination_id
    and je_header_id in (select je_header_id from gl_je_headers  where
    BUDGET_VERSION_ID in (select Bv.budget_version_id from gl_budget_versions Bv , gl_balances bal  where BUDGET_NAME = 'BUDGET 2014_2' and actual_flag= 'B'))
    and gcc.segment3 between 3100000000 and 3199999999 and gcc.segment2 =31
    group by GCC.segment1,GCC.segment2,GCC.segment3,GCC.segment4,GCC.segment5,
    GCC.segment6, DECODE(gcc.segment6,NULL,'',SUBSTR(apps.gl_flexfields_pkg.get_description_sql
    (gcc.chart_of_accounts_id,6,gcc.segment6),1,40))
    Query 2
    SELECT distinct GCC.segment1,GCC.segment2,GCC.segment3,GCC.segment4,GCC.segment5,
    GCC.segment6, DECODE(gcc.segment6,NULL,'',SUBSTR(apps.gl_flexfields_pkg.get_description_sql( gcc.chart_of_accounts_id,6,gcc.segment6),1,40))
    DETAILS,sum(gje.accounted_dr) BUDGET_2011
    FROM  gl_je_lines gje, gl_code_combinations gcc
    WHERE gje.code_combination_id(+)=gcc.code_combination_id
    and je_header_id in (select je_header_id from gl_je_headers  where
    BUDGET_VERSION_ID in (select Bv.budget_version_id from gl_budget_versions Bv , gl_balances bal  where BUDGET_NAME = '2011 BUDGET' and actual_flag= 'B'))
    and gcc.segment3 between 3100000000 and 3199999999 and gcc.segment2 =31
    group by GCC.segment1,GCC.segment2,GCC.segment3,GCC.segment4,GCC.segment5,
    GCC.segment6, DECODE(gcc.segment6,NULL,'',SUBSTR(apps.gl_flexfields_pkg.get_description_sql
    (gcc.chart_of_accounts_id,6,gcc.segment6),1,40))

    fermusic said...
    "use I/O plugin in the Master 1-2 Output ... you will be able to route the signal to 3-4... or wherever you need.... just Bypass I/O plugin to return at 1-2 OUTs"
    Thank you!
    That's exactly how it works.
    With the output assigned to 3-4 and input to 1-2, toggling the Bypass button switches the output.
    And I don't have to replicate processors on the output 3-4 bus.
    Very cool.
    Cheers.

  • I WANT THE RESULT PAGE OF MY INSERT FORM TO BE AN UPDATE FORM OF THE JUST INSERTED DATA

    I WANT THE RESULT PAGE OF MY INSERT FORM TO BE AN UPDATE FORM OF THE JUST INSERTED DATA USING ADDT. PLS HELP WITH EXMPLE . THANKS

    let me xplain
    i am trying to create a 3  page form. i used the insert form wizard to create the first form and ask the form to go to the next page which i made an update form to continue the next set of fields. i tried what u said...but the next form did not add records to the database as i expected.below is my code for the two pages. pls tell me the best approach..thanks
    page 1
    <?php require_once('Connections/crusader.php'); ?>
    <?php
    //MX Widgets3 include
    require_once('includes/wdg/WDG.php');
    // Load the common classes
    require_once('includes/common/KT_common.php');
    // Load the tNG classes
    require_once('includes/tng/tNG.inc.php');
    // Make a transaction dispatcher instance
    $tNGs = new tNG_dispatcher("");
    // Make unified connection variable
    $conn_crusader = new KT_connection($crusader, $database_crusader);
    // Start trigger
    $formValidation = new tNG_FormValidation();
    $tNGs->prepareValidation($formValidation);
    // End trigger
    // Make an insert transaction instance
    $ins_capital = new tNG_insert($conn_crusader);
    $tNGs->addTransaction($ins_capital);
    // Register triggers
    $ins_capital->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
    $ins_capital->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
    $ins_capital->registerTrigger("END", "Trigger_Default_Redirect", 99, "top.php");
    // Add columns
    $ins_capital->setTable("capital");
    $ins_capital->addColumn("cap_firstname", "STRING_TYPE", "POST", "cap_firstname");
    $ins_capital->addColumn("cap_username", "STRING_TYPE", "POST", "cap_username");
    $ins_capital->addColumn("cap_lastname", "STRING_TYPE", "POST", "cap_lastname");
    $ins_capital->addColumn("cap_dateofbirth", "DATE_TYPE", "POST", "cap_dateofbirth", "{NOW}");
    $ins_capital->addColumn("cap_sex", "STRING_TYPE", "POST", "cap_sex");
    $ins_capital->setPrimaryKey("cap_id", "NUMERIC_TYPE");
    // Execute all the registered transactions
    $tNGs->executeTransactions();
    // Get the transaction recordset
    $rscapital = $tNGs->getRecordset("capital");
    $row_rscapital = mysql_fetch_assoc($rscapital);
    $totalRows_rscapital = mysql_num_rows($rscapital);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wdg="http://ns.adobe.com/addt">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
    <script src="includes/common/js/base.js" type="text/javascript"></script>
    <script src="includes/common/js/utility.js" type="text/javascript"></script>
    <script src="includes/skins/style.js" type="text/javascript"></script>
    <?php echo $tNGs->displayValidationRules();?>
    <script type="text/javascript" src="includes/common/js/sigslot_core.js"></script>
    <script type="text/javascript" src="includes/wdg/classes/MXWidgets.js"></script>
    <script type="text/javascript" src="includes/wdg/classes/MXWidgets.js.php"></script>
    <script type="text/javascript" src="includes/wdg/classes/Calendar.js"></script>
    <script type="text/javascript" src="includes/wdg/classes/SmartDate.js"></script>
    <script type="text/javascript" src="includes/wdg/calendar/calendar_stripped.js"></script>
    <script type="text/javascript" src="includes/wdg/calendar/calendar-setup_stripped.js"></script>
    <script src="includes/resources/calendar.js"></script>
    </head>
    <body>
    <p> 
      <?php
        echo $tNGs->getErrorMsg();
    ?>
    <form method="post" id="form1" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>">
      <table cellpadding="2" cellspacing="0" class="KT_tngtable">
        <tr>
          <td class="KT_th"><label for="cap_firstname">Cap_firstname:</label></td>
          <td><input type="text" name="cap_firstname" id="cap_firstname" value="<?php echo KT_escapeAttribute($row_rscapital['cap_firstname']); ?>" size="32" />
            <?php echo $tNGs->displayFieldHint("cap_firstname");?> <?php echo $tNGs->displayFieldError("capital", "cap_firstname"); ?></td>
        </tr>
        <tr>
          <td class="KT_th"><label for="cap_lastname">Cap_lastname:</label></td>
          <td><input type="text" name="cap_lastname" id="cap_lastname" value="<?php echo KT_escapeAttribute($row_rscapital['cap_lastname']); ?>" size="32" />
            <?php echo $tNGs->displayFieldHint("cap_lastname");?> <?php echo $tNGs->displayFieldError("capital", "cap_lastname"); ?></td>
        </tr>
        <tr>
          <td class="KT_th"><label for="cap_dateofbirth">Cap_dateofbirth:</label></td>
          <td><input name="cap_dateofbirth" id="cap_dateofbirth" value="<?php echo KT_formatDate($row_rscapital['cap_dateofbirth']); ?>" size="32" wdg:mondayfirst="false" wdg:subtype="Calendar" wdg:mask="<?php echo $KT_screen_date_format; ?>" wdg:type="widget" wdg:singleclick="true" wdg:restricttomask="no" />
            <?php echo $tNGs->displayFieldHint("cap_dateofbirth");?> <?php echo $tNGs->displayFieldError("capital", "cap_dateofbirth"); ?></td>
        </tr>
        <tr>
          <td class="KT_th"><label for="cap_sex">Cap:</label></td>
          <td><input type="text" name="cap_sex" id="cap_sex" value="<?php echo KT_escapeAttribute($row_rscapital['cap_sex']); ?>" size="32" />
            <?php echo $tNGs->displayFieldHint("cap_sex");?> <?php echo $tNGs->displayFieldError("capital", "cap_sex"); ?></td>
        </tr>
        <tr class="KT_buttons">
          <td colspan="2"><input type="submit" name="KT_Insert1" id="KT_Insert1" value="Insert record" /></td>
        </tr>
      </table>
    </form>
    <p> </p>
    </p>
    </body>
    </html>
    Page2
    <?php require_once('Connections/crusader.php'); ?>
    <?php
    // Load the common classes
    require_once('includes/common/KT_common.php');
    // Load the tNG classes
    require_once('includes/tng/tNG.inc.php');
    // Make a transaction dispatcher instance
    $tNGs = new tNG_dispatcher("");
    // Make unified connection variable
    $conn_crusader = new KT_connection($crusader, $database_crusader);
    // Start trigger
    $formValidation = new tNG_FormValidation();
    $tNGs->prepareValidation($formValidation);
    // End trigger
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    mysql_select_db($database_crusader, $crusader);
    $query_rdd = "SELECT * FROM capital ORDER BY cap_id DESC LIMIT 1";
    $rdd = mysql_query($query_rdd, $crusader) or die(mysql_error());
    $row_rdd = mysql_fetch_assoc($rdd);
    $totalRows_rdd = mysql_num_rows($rdd);
    // Make an update transaction instance
    $upd_capital = new tNG_update($conn_crusader);
    $tNGs->addTransaction($upd_capital);
    // Register triggers
    $upd_capital->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Update1");
    $upd_capital->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
    // Add columns
    $upd_capital->setTable("capital");
    $upd_capital->addColumn("cap_firstname", "STRING_TYPE", "POST", "cap_firstname");
    $upd_capital->addColumn("cap_dateofbirth", "DATE_TYPE", "POST", "cap_dateofbirth");
    $upd_capital->addColumn("cap_mobilephone", "STRING_TYPE", "POST", "cap_mobilephone");
    $upd_capital->addColumn("cap_occupation", "STRING_TYPE", "POST", "cap_occupation");
    $upd_capital->addColumn("cap_sumassured", "STRING_TYPE", "POST", "cap_sumassured");
    $upd_capital->setPrimaryKey("cap_id", "NUMERIC_TYPE", "GET", "cap_id");
    // Execute all the registered transactions
    $tNGs->executeTransactions();
    // Get the transaction recordset
    $rscapital = $tNGs->getRecordset("capital");
    $row_rscapital = mysql_fetch_assoc($rscapital);
    $totalRows_rscapital = mysql_num_rows($rscapital);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
    <script src="includes/common/js/base.js" type="text/javascript"></script>
    <script src="includes/common/js/utility.js" type="text/javascript"></script>
    <script src="includes/skins/style.js" type="text/javascript"></script>
    <?php echo $tNGs->displayValidationRules();?>
    </head>
    <body>
    <p> 
    <p> 
      <?php
        echo $tNGs->getErrorMsg();
    ?>
    <form method="post" id="form1" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>">
      <table cellpadding="2" cellspacing="0" class="KT_tngtable">
        <tr>
          <td class="KT_th"><label for="cap_firstname">Cap_firstname:</label></td>
          <td><input type="text" name="cap_firstname" id="cap_firstname" value="<?php echo KT_escapeAttribute($row_rdd['cap_firstname']); ?>" size="32" />
            <?php echo $tNGs->displayFieldHint("cap_firstname");?> <?php echo $tNGs->displayFieldError("capital", "cap_firstname"); ?></td>
        </tr>
        <tr>
          <td class="KT_th"><label for="cap_dateofbirth">Cap_dateofbirth:</label></td>
          <td><input type="text" name="cap_dateofbirth" id="cap_dateofbirth" value="<?php echo KT_formatDate($row_rdd['cap_dateofbirth']); ?>" size="32" />
          <?php echo $tNGs->displayFieldHint("cap_dateofbirth");?> <?php echo $tNGs->displayFieldError("capital", "cap_dateofbirth"); ?></td>
        </tr>
        <tr>
          <td class="KT_th"><label for="cap_mobilephone">Cap_mobilephone:</label></td>
          <td><input type="text" name="cap_mobilephone" id="cap_mobilephone" value="<?php echo KT_escapeAttribute($row_rdd['cap_mobilephone']); ?>" size="32" />
          <?php echo $tNGs->displayFieldHint("cap_mobilephone");?> <?php echo $tNGs->displayFieldError("capital", "cap_mobilephone"); ?></td>
        </tr>
        <tr>
          <td class="KT_th"><label for="cap_occupation">Cap_occupation:</label></td>
          <td><input type="text" name="cap_occupation" id="cap_occupation" value="<?php echo KT_escapeAttribute($row_rdd['cap_occupation']); ?>" size="32" />
          <?php echo $tNGs->displayFieldHint("cap_occupation");?> <?php echo $tNGs->displayFieldError("capital", "cap_occupation"); ?></td>
        </tr>
        <tr>
          <td class="KT_th"><label for="cap_sumassured">Cap_sumassured:</label></td>
          <td><input type="text" name="cap_sumassured" id="cap_sumassured" value="<?php echo KT_escapeAttribute($row_rdd['cap_sumassured']); ?>" size="32" />
          <?php echo $tNGs->displayFieldHint("cap_sumassured");?> <?php echo $tNGs->displayFieldError("capital", "cap_sumassured"); ?></td>
        </tr>
        <tr class="KT_buttons">
          <td colspan="2"><input type="submit" name="KT_Update1" id="KT_Update1" value="Update record" /></td>
        </tr>
      </table>
    </form>
    <p> </p>
    </p>
    </p>
    </body>
    </html>
    <?php
    mysql_free_result($rdd);
    ?>

Maybe you are looking for