CONCAT in MySQL

Hi, I am trying to use recordset with CONCAT function in
SELECT, and it always gets distorted by, it seems, Dreamweaver.
Is there a workaround?

JStefano wrote:
> Hi, I am trying to use recordset with CONCAT function in
SELECT, and it always gets distorted by, it seems, Dreamweaver.
It sounds as though you're using Dreamweaver 8.0.2. Go to the
following
page, and download the PHP extension fix (the link is in the
first
paragraph):
http://www.adobe.com/go/b6c2ae2a
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of
ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Similar Messages

  • Does EJBQL in JDeveloper support max aggregate function ?

    Does EJBQL in JDeveloper support max aggregate function ?
    I can't get it to work using select max(o.time) from MyObject o; It always returns the MyObject to me.
    Anybody knows how to do this ?
    Thanks.

    No one knows how exactly this works in JDeveloper 11g? As I see it, it's most likely a bug. For one, JDeveloper already supports plenty of databases and enforces some limitations on the useability of these databases where necessary (for instance, JDBC Positioning instead of Oracle's way of binding for the bind variables in a query). However, this enforcement does not happen with the WHERE clause of the view criteria in MySQL when you choose an operator that concatenates strings together in the WHERE clause, such as "contains". You'd expect it's smart enough to use different syntax for concatenating the strings, depending on the database (e.g., CONCAT for MySQL, || for Oracle). Second, lack of this enforcement should not break functionality, and here it does (searching with wildcards in LOV is just not possible declaratively with MySQL), which resembles a bug in the software.
    For now, I've completely rewritten the LOV in Java, so it's not declarative anymore, but programmatic. It works, resembles searching with "contains" and it stays that way, despite of the higher difficulty in maintenance, until this issue can be solved declaratively, by any means: via a patch release or via a workaround. I hope someone can provide me (and quite possibly others facing this issue) with insight upon this.
    Thanks in advance.

  • Concat java variable to a MySql select statement and exeucte

    Hi,
    I am trying to append a variable to a MySql select statement.
    Overview: I need to retrieve data from a MySql database with a java variable as a reference and select the data in the database based on that variable.
    CODE THAT I CURRENTLY HAVE:
    // Declare variables
    Connection conn = null;
    Statement st = null;
    Resultset rs2 = null;
    String st2 = null;
    String keyid = null;
    // Connect to database
    try {
          Class.forName("org.gjt.mm.mysql.Driver").newInstance();
          conn = DriverManager.getConnection("jdbc:mysql://" + mysql_host + ":3306/" + mysql_database, mysql_login, mysql_password);
          st = conn.createStatement();
          // Select data in Database with hanging equal sign
          st2 = ("SELECT * FROM table WHERE keyid= ");
          // Append keyid to hanging equal sign of select statement
          rs2 = st.executeQuery(st2 + keyid);
    }This is not working when I try to display the data.

    What is not working about it? Is there an error message? Stack Trace?
    Where do you get the value of keyId from?
    I would suggest that you use a prepared statement rather than building up a sql string like this. It prevents sql injection attacks
    // Declare variables
    Connection conn = null;
    PreparedStatement stmt = null;
    Resultset rs2 = null;
    String sql= null;
    String keyid = null;
    // Connect to database
    try {
          Class.forName("org.gjt.mm.mysql.Driver").newInstance();
          conn = DriverManager.getConnection("jdbc:mysql://" + mysql_host + ":3306/" + mysql_database, mysql_login, mysql_password);
          // Select data in Database with place holder for parameter
          sql = "SELECT * FROM table WHERE keyid= ?";
           // prepare the statement
          stmt = conn.prepareStatement(sql);
          // set the value of key id to use with the query
          stmt.setString(1, keyId);
          // run the query
          rs2 = st.executeQuery();
    catch (Exception e){
      System.out.println("An error occurred " + e.getMessage());
      e.printStackTrace();
    finally{
      if (rs2 != null) try { rs2.close(); } catch(SQLException ex){}
      if (stmt != null) try { stmt.close(); } catch(SQLException ex){}
      if (conn != null) try { con.close(); } catch(SQLException ex){}
    }

  • Toggle mysql concat sql query

    I have a drop down menu on a form that lists GPs by their surname, surgery name and town:
    $query_gp = "SELECT CONCAT(gp_surname, ' - ', gp_surgery, ', ', gp_town) as gplist, gp_id  FROM gp ORDER BY gplist";
    $gp = mysql_query($query_gp, $mypms) or die(mysql_error());
    $row_gp = mysql_fetch_assoc($gp);
    $totalRows_gp = mysql_num_rows($gp);
    and then the php to put on the page and update a foreign key in a separate table:
    <select name="gplist" class="main_text_field" id="gplist"style="width:150px;">
    <?php
         do { 
    ?>
    <option value="<?php echo $row_gp['gp_id']?>"<?php if (!(strcmp($row_gp['gp_id'], $row_demographics['FK_gp_id']))) {echo "SELECTED";} ?>><?php echo $row_gp['gplist']?></option>
    <?php
         } while ($row_gp = mysql_fetch_assoc($gp));
         $rows = mysql_num_rows($gp);#
         if($rows > 0) {
              mysql_data_seek($gp, 0);
              $row_gp = mysql_fetch_assoc($gp);
    ?>
                </select>
    Using a pair of radio buttons, I want to toggle the list order so that it is displayed in town order, I haven't got the foggiest about where to start - help please :-(

    I am assuming what Bregent and Nancy mean is to allocate a value to the radio buttons then send that value to the page to process in what order you want the list to appear, either ORDER by gplist or gp_town
    <form action="xxxxxxxxxx.php" method="post">
    <input type="radio" name="gp" value="gpName">List by GP Name<br>
    <input type="radio" name="gp" value="gpTown">List by Town
    <input type="submit" value="Submit">
    </form>
    You would then use some php to get the value of 'gp' - the 'name' given to the radio button group (as above). The value of the radio button is assigned to a variable called $action and then re-assigned with the database column name you want the list to be ORDERED by.
    <?php
    $action = $_POST['gp'];
    if ($action == "gpName") {
    $action = "gplist";
    elseif ($action == "gpTown") {
    $action = "gp_town";
    ?>
    Enclose the database query in a php if/else statement. IF the variable $action 'isset' then the list will be ordered by whatever radio button value is selected otherwise it will just be ordered by gplist:
    if(isset($action)) {
    $query_gp = "SELECT CONCAT(gp_surname, ' - ', gp_surgery, ', ', gp_town) as gplist, gp_id  FROM gp ORDER BY '".$action."' ASC";
    $gp = mysql_query($query_gp, $mypms) or die(mysql_error());
    $row_gp = mysql_fetch_assoc($gp);
    $totalRows_gp = mysql_num_rows($gp);
    else {
    $query_gp = "SELECT CONCAT(gp_surname, ' - ', gp_surgery, ', ', gp_town) as gplist, gp_id  FROM gp ORDER BY gplist";
    $gp = mysql_query($query_gp, $mypms) or die(mysql_error());
    $row_gp = mysql_fetch_assoc($gp);
    $totalRows_gp = mysql_num_rows($gp);

  • How Can I use Mysql's  PROCEDURE by Java Can you give me sample???

    �������^���������������H�iBEGIN�`END�u���b�N�j�@��TOP
    ORACLE�@MSSQL�@SSA�@MySQL�@
    ���{�I���������������������������B
    MySQL�������A ORACLE��MSSSQL��������������BEGIN�`END�u���b�N�����s�������������������������B
    ���������s�������������K���X�g�A�h�v���O�����������R���p�C�������K�v�����������B
    �i�����F�������������������A���w�E�������������K�r�����������j
    --drop PROCEDURE sp_hoge;
    --�f���~�^�����X��������
    delimiter //
    CREATE PROCEDURE sp_hoge()
    DETERMINISTIC
    BEGIN
    /* �������� */
    DECLARE mystr VARCHAR(20);
    DECLARE mycnt INTEGER(2);
    /* �l������ */
    SET mycnt = 0;
    SET mystr = '����';
    /* IF�� */
    IF mycnt = 0 THEN
    SET mystr = '�����Q';
    select mystr;
    ELSE
    select '�����R';
    END IF;
    /* CASE�� */
    CASE extract(month from now())
    WHEN 1 THEN SET mystr = '1��';
    WHEN 2 THEN SET mystr = '2��';
    WHEN 3 THEN SET mystr = '3��';
    WHEN 4 THEN SET mystr = '4��';
    ELSE SET mystr = '1�`4�����O';
    END CASE;
    select mystr;
    /* WHILE-LOOP */
    WHILE mycnt <= 5 DO
    SET mycnt = mycnt + 1;
    select mycnt;
    END WHILE;
    /* BEGIN-END�u���b�N������SELECT�������s */
    /* PROCEDURE�������\�iFUNCTION���������������j */
    select * from help_topic;
    END//
    delimiter ;
    --�X�g�A�h�v���V�[�W�����s
    call sp_hoge();
    �X�g�A�h�v���V�[�W�����T���v���i�J�[�\�����g�p������LOOP�����j�@��TOP
    ORACLE�@MSSQL�@SSA�@MySQL�@
    �J�[�\�����g�p����LOOP�������T���v�������B
    �����p�����[�^���w�����������������Y�������������������A���E���w�X�^�b�t�x�������������A�����������w�c���X�^�b�t�F�x���\���������B
    --drop PROCEDURE sp_hoge;
    --�f���~�^�����X��������
    delimiter //
    CREATE PROCEDURE sp_hoge(inum INTEGER(3))
    DETERMINISTIC
    BEGIN
    /* �������� */
    /* �J�[�\���g�p�����f�[�^�L�����f���g�p */
    DECLARE done INT DEFAULT 0;
    /* �������O������ */
    DECLARE v_mystr VARCHAR(20);
    /* �J�[�\���g�p�� */
    DECLARE v_empnm VARCHAR(40);
    DECLARE v_job VARCHAR(20);
    /* �J�[�\������ �� �����������������`���� */
    DECLARE cur1 CURSOR FOR
    select empnm,job from kemp where deptno = inum;
    /* �f�[�^��������LOOP�E�o�p���������� */
    DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
    /* �J�[�\���I�[�v�� */
    OPEN cur1;
    /* LOOP */
    LOOPPROC:REPEAT
    FETCH cur1 INTO v_empnm,v_job;
    IF NOT done THEN
    IF v_job = '�X�^�b�t' THEN
    SET v_mystr = '�c���X�^�b�t�F';
    ELSE
    SET v_mystr = '';
    END IF;
    select CONCAT(v_mystr,v_empnm);
    /* ������������LOOP���E�o����������LEAVE�� */
    /* LEAVE LOOPPROC; */
    END IF;
    UNTIL done END REPEAT;
    /* �J�[�\���N���[�Y */
    CLOSE cur1;
    END//
    --�f���~�^���Z�~�R�����i�f�t�H���g�j������������
    delimiter ;
    --�X�g�A�h�v���V�[�W�����s
    call sp_hoge(1);
    12.2. Control Flow Functions
    CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result ...] [ELSE result] END
    CASE WHEN [condition] THEN result [WHEN [condition] THEN result ...] [ELSE result] END
    The first version returns the result where value=compare_value. The second version returns the result for the first condition that is true. If there was no matching result value, the result after ELSE is returned, or NULL if there is no ELSE part.
    mysql> SELECT CASE 1 WHEN 1 THEN 'one'
    -> WHEN 2 THEN 'two' ELSE 'more' END;
    -> 'one'
    mysql> SELECT CASE WHEN 1>0 THEN 'true' ELSE 'false' END;
    -> 'true'
    mysql> SELECT CASE BINARY 'B'
    -> WHEN 'a' THEN 1 WHEN 'b' THEN 2 END;
    -> NULL
    The default return type of a CASE expression is the compatible aggregated type of all return values, but also depends on the context in which it is used. If used in a string context, the result is returned as a string. If used in a numeric context, then the result is returned as a decimal, real, or integer value.
    Note: The syntax of the CASE expression shown here differs slightly from that of the SQL CASE statement described in Section 17.2.10.2, �gCASE Statement�h, for use inside stored routines. The CASE statement cannot have an ELSE NULL clause, and it is terminated with END CASE instead of END.
    IF(expr1,expr2,expr3)
    If expr1 is TRUE (expr1 <> 0 and expr1 <> NULL) then IF() returns expr2; otherwise it returns expr3. IF() returns a numeric or string value, depending on the context in which it is used.
    mysql> SELECT IF(1>2,2,3);
    -> 3
    mysql> SELECT IF(1<2,'yes','no');
    -> 'yes'
    mysql> SELECT IF(STRCMP('test','test1'),'no','yes');
    -> 'no'
    If only one of expr2 or expr3 is explicitly NULL, the result type of the IF() function is the type of the non-NULL expression.
    expr1 is evaluated as an integer value, which means that if you are testing floating-point or string values, you should do so using a comparison operation.
    mysql> SELECT IF(0.1,1,0);
    -> 0
    mysql> SELECT IF(0.1<>0,1,0);
    -> 1
    In the first case shown, IF(0.1) returns 0 because 0.1 is converted to an integer value, resulting in a test of IF(0). This may not be what you expect. In the second case, the comparison tests the original floating-point value to see whether it is non-zero. The result of the comparison is used as an integer.
    The default return type of IF() (which may matter when it is stored into a temporary table) is calculated as follows:
    Expression Return Value
    expr2 or expr3 returns a string string
    expr2 or expr3 returns a floating-point value floating-point
    expr2 or expr3 returns an integer integer
    If expr2 and expr3 are both strings, the result is case sensitive if either string is case sensitive.
    Note: There is also an IF statement, which differs from the IF() function described here. See Section 17.2.10.1, �gIF Statement�h.
    IFNULL(expr1,expr2)
    If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2. IFNULL() returns a numeric or string value, depending on the context in which it is used.
    mysql> SELECT IFNULL(1,0);
    -> 1
    mysql> SELECT IFNULL(NULL,10);
    -> 10
    mysql> SELECT IFNULL(1/0,10);
    -> 10
    mysql> SELECT IFNULL(1/0,'yes');
    -> 'yes'
    The default result value of IFNULL(expr1,expr2) is the more �ggeneral�h of the two expressions, in the order STRING, REAL, or INTEGER. Consider the case of a table based on expressions or where MySQL must internally store a value returned by IFNULL() in a temporary table:
    mysql> CREATE TABLE tmp SELECT IFNULL(1,'test') AS test;
    mysql> DESCRIBE tmp;
    -------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    -------------------------------------------+
    | test | char(4) | | | | |
    -------------------------------------------+
    In this example, the type of the test column is CHAR(4).
    NULLIF(expr1,expr2)
    Returns NULL if expr1 = expr2 is true, otherwise returns expr1. This is the same as CASE WHEN expr1 = expr2 THEN NULL ELSE expr1 END.
    mysql> SELECT NULLIF(1,1);
    -> NULL
    mysql> SELECT NULLIF(1,2);
    -> 1
    Note that MySQL evaluates expr1 twice if the arguments are not equal.
    Previous / Next / Up / Table of Contents
    User Comments
    Posted by I W on July 12 2005 5:52pm [Delete] [Edit]
    Don't use IFNULL for comparisons (especially not for Joins)
    (example:
    select aa from a left join b ON IFNULL(a.col,1)=IFNULL(b.col,1)
    It's terrible slow (ran for days on two tables with approx 250k rows).
    Use <=> (NULL-safe comparison) instead. It did the same job in less than 15 minutes!!
    Posted by [name withheld] on November 10 2005 12:12am [Delete] [Edit]
    IFNULL is like oracle's NVL function (these should help people searching for NVL() ..)
    Posted by Philip Mak on May 26 2006 7:14am [Delete] [Edit]
    When using CASE, remember that NULL != NULL, so if you write "WHEN NULL", it will never match. (I guess you have to use IFNULL() instead...)
    Posted by Marc Grue on June 24 2006 2:03pm [Delete] [Edit]
    You can ORDER BY a dynamic column_name parameter using a CASE expression in the ORDER BY clause of the SELECT statement:
    CREATE PROCEDURE `orderby`(IN _orderby VARCHAR(50))
    BEGIN
    SELECT id, first_name, last_name, birthday
    FROM table
    ORDER BY
    -- numeric columns
    CASE _orderby WHEN 'id' THEN id END ASC,
    CASE orderby WHEN 'desc id' THEN id END DESC,
    -- string columns
    CASE orderby WHEN 'firstname' THEN first_name WHEN 'last_name' THEN last_name END ASC,
    CASE orderby WHEN 'descfirst_name' THEN first_name WHEN 'desc_last_name' THEN last_name END DESC,
    -- datetime columns
    CASE _orderby WHEN 'birthday' THEN birthday END ASC,
    CASE orderby WHEN 'desc birthday' THEN birthday END DESC;
    END
    Since the CASE expression returns the "compatible aggregated type of all return values", you need to isolate each column type in a separate CASE expression to get the desired result.
    If you mixed the columns like
    CASE _orderby
    WHEN 'id' THEN id
    WHEN 'first_name' THEN first_name
    ...etc...
    END ASC
    .. both the id and first_name would be returned as a string value, and ids would be sorted as a string to '1,12,2,24,5' and not as integers to '1,2,5,12,24'.
    Note that you don't need a "ELSE null" in the CASE expressions, since the CASE expression automatically returns null if there's no match. In that case, you get a "null ASC" in your ORDER BY clause which doesn't affect the sort order. If for instance orderby is 'descfirst_name', the ORDER BY clause evaluates to:
    ORDER BY null ASC, null DESC, null ASC, first_name DESC, null ASC, null DESC
    Effectively the same as "ORDER BY first_name DESC". You could even add a new set of CASE expressions for a second order column (or more..) if you like.
    Add your own comment.

    What is that post supposed to be?

  • MySql / Oracle special characters

    Searched all around, my apologies if this is a redundant thread.
    I have an Oracle (10.2.0.3) database set up to connect to MySql (4.1) database using HSODBC. Using the 3.51 MySql driver. Has a couple bugs. Distributed transactions, erroneous record counts, etc -- but I know from reading other threads that the fixes are coming. There is one problem I can't seem to get around...
    In MySql, a certain field is defined as CHAR(40). I would think any content short of 40 characters is padded with spaces. But when I pull pipeline characters concatenated on both sides of the values (MySql query browser), there are no extra spaces. It's behaving more like a VARCHAR on the MySql end:
    [select concat( '|', field, '|') from table]
    returns '|value|'
    NOT '|value |'
    Now, when I pull this data through to Oracle, there are special characters padding the content to the length of the column. When I pull the ASCII code value, they're 0 NUL (null) characters. Every CHAR field in every table that doesn't fill the column is coming across the database link padded with these NUL characters, which look like little hollow squares (in SqlDeveloper and JDeveloper). Since they're not spaces, I can't TRIM them out. I can remove them with TRANSLATE, but I would have to identify every CHAR field in every table and manually code a TRANSLATE into views against the DB_LINK, and then always pull from the views. There must be an easier way to get around this.
    Has anybody had a similar experience? Is this the version of the MySql driver (3.51) that I'm using? I see they have a version 5 out now. Is this addressed by a 10.2.0.4 patchset? Is that available yet? (Redhat) Is this fixed with 11g?
    Oracle - AL32UTF8, UTF8
    MySql - uses both UTF8 and Latin1, but the default on the source table is Latin1 / Latin_swedish_ci

    The problem is a MySQL ODBC driver issue.
    You have to enable ODBC option 512 (pad char to full length):
    Default behaviour of the MySQL ODBC is not to PAD spaces:
    SQL> select dump( "col1") from "counter"@mysql;
    DUMP("COL1")
    Typ=96 Len=20: 72,101,108,108,111,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    As you can see the char column is padded with 0 instead of spaces (32).
    As soon as you add OPTION 512 to the ODBC.INI (please make sure if you already have a value set for OPTION to add 512 on top of your value to get your dedicated value). So the ODBC.INI might look like:
    [mysql]
    Description = MySQL database test
    Driver = /usr/lib/libmyodbc3.so
    #Driver = MySQL ODBC 3.51 Driver
    OPTION = 512
    and then MySQL behaves correctly:
    SQL> select dump( "col1") from "counter"@mysql;
    DUMP("COL1")
    Typ=96 Len=20: 72,101,108,108,111,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32

  • PHP, MySQL, Breadcrumbs and URL Parameters

    I'm working with several InterAKT extensions to buid a
    dynamic site. I have everything working except for Breadcrumbs --
    which are actually working except that I need to change the URL
    parameter which they are passing WITHOUT altering the recordset
    (which breaks the functionality).
    The site is constructed to include friendly URLS, so although
    all pages are loaded by PK of their category, I've used CONCAT()
    and REPLACE() along with Server-Side Includes from my Table (SSI
    from InterAKT) to generate my URLS.
    Example:
    category_ctg TABLE
    id_ctg name_ctg
    1 Jelly Beans
    2 Vanilla Nut Crunch Bar
    etc.
    For my dynamic menus and my hyperlinks, I pull from the db
    like this:
    SELECT *, CONCAT(REPLACE(name_ctg, ' ', '-'), '?id_ctg=',
    id_ctg) AS newurl FROM category_ctg
    This gives me a URL of
    index.php/Vanilla-Nut-Crunch-Bar?id_ctg=2
    (I also pull from the name_ctg field for my page titles and menu
    names, etc., without the CONCAT() so they read without the '-')
    But, with MX Breadcrumbs I'm limited to the way the php is
    hard-coded in terms of which fields are included: (id_ctg,
    id_parent_ctg and name_ctg) because the breadcrumbs are generated
    from a recordset.inc.php file.
    I can succesfully use the Breadcrumbs "out-of-the-box" and
    end up with this URL:
    index.php?id_ctg=2
    My code for above looks like this:
    <?php if ($totalRows_Breadcrumbs > 0) { // Show if
    recordset not empty ?>
    &gt; <a href="index.php?id_ctg=<?php echo
    $row_Breadcrumbs['id_ctg']; ?>"><?php echo
    $row_Breadcrumbs['name_ctg']; ?></a>
    <?php } // Show if recordset not empty ?>
    and while it works, it's loading a different URL than all my
    other menus and links.
    Alternatively, I can include the catgeory_ctg.name_ctg
    dynamic binding like this:
    <?php do { ?>
    <?php if ($totalRows_Breadcrumbs > 0) { // Show if
    recordset not empty ?>
    &gt; <a href="<?php echo
    $row_Breadcrumbs['name_ctg']; ?>?id_ctg=<?php echo
    $row_Breadcrumbs['id_ctg']; ?>"><?php echo
    $row_Breadcrumbs['name_ctg']; ?></a>
    <?php } // Show if recordset not empty ?>
    <?php } while ($row_Breadcrumbs =
    mysql_fetch_assoc($Breadcrumbs)); ?>
    which gives me a URL of:
    index.php/Vanilla%20Nut%20Crunch%20Bar?id_ctg=9
    Since I can't use CONCAT() value within my script and I can't
    have "%20" in my URLs, I'm trying to find a way of turning my URL
    into:
    index.php/Vanilla-Nut-Crunch-Bar?id_ctg=2
    Is there a way to include the CONCAT() function in the PHP
    script that's generating the URL?
    I've tried using variables in the header to call for a
    consistent URL, without any luck.
    Please keep in mind that my strong suit is design and that my
    working knowledge of PHP and MySQL are limited to what I can
    understand and re-create. I've been pulling out my hair for days on
    this, so some guidance would be
    greatly appreciated.

    The code generated by the Dreamweaver recordset navigation bar automatically adds any existing variables to the end of the query string. The following code (just above the DOCTYPE) comes from a recordset navigation bar on one of my pages:
    $queryString_listAuthors = "";
    if (!empty($_SERVER['QUERY_STRING'])) {
      $params = explode("&", $_SERVER['QUERY_STRING']);
      $newParams = array();
      foreach ($params as $param) {
        if (stristr($param, "pageNum_listAuthors") == false &&
            stristr($param, "totalRows_listAuthors") == false) {
          array_push($newParams, $param);
      if (count($newParams) != 0) {
        $queryString_listAuthors = "&" . htmlentities(implode("&", $newParams));
    $queryString_listAuthors = sprintf("&totalRows_listAuthors=%d%s", $totalRows_listAuthors, $queryString_listAuthors);
    I haven't tested this, but to eliminate the extra variables in the query string, comment out the whole of the if statement like this:
    $queryString_listAuthors = "";
    if (!empty($_SERVER['QUERY_STRING'])) {
      $params = explode("&", $_SERVER['QUERY_STRING']);
      $newParams = array();
      foreach ($params as $param) {
        if (stristr($param, "pageNum_listAuthors") == false &&
            stristr($param, "totalRows_listAuthors") == false) {
          array_push($newParams, $param);
      if (count($newParams) != 0) {
        $queryString_listAuthors = "&" . htmlentities(implode("&", $newParams));
    $queryString_listAuthors = sprintf("&totalRows_listAuthors=%d%s", $totalRows_listAuthors, $queryString_listAuthors);
    You will need to do that for each of your recordset navigation bars.

  • Concat with nulls

    I am running a query that sends the results to a pdf form. In
    the select statement I am concating first, middle, and last names.
    My select looks like this: SELECT concat(p1title, " ",
    p1FirstName, " ", p1middlename, " ", p1lastname) AS
    p1name...(snip). As long as the DB has info in all fields it
    returns results. If, for instance p1middlename is null, it does not
    return anything. What would be the best way to fix this problem?
    TIA.

    I guess the DB is MySql.
    Please check this.
    http://bugs.mysql.com/bug.php?id=480
    Hope this will help you.
    Thanks
    Sankalan
    (www.mindfiresolutions.com)

  • MySQL Stored procedure, INOUT parameter question.

    Hello, I'm trying to run a stored procedure in MySQL 5.0 through the use of Java. Here's what I have:
    Part of my Java code (which is taken from the MySQL Connector/J documentation):
        CallableStatement cStmt = conn.prepareCall("{call demoSp(?, ?)}");                                   
        cStmt.registerOutParameter("inOutParam", Types.INTEGER);
        cStmt.setString(1, "hello");
        cStmt.setInt("inOutParam", 4);
        cStmt.execute();
        System.out.println(cStmt.getInt("inOutParam"));The stored procedure (which has been taken directly from the MySQL Connector/J documentation, PDF format, Page 4)
    CREATE PROCEDURE demoSp(IN inputParam VARCHAR(255), INOUT inOutParam INT)
    BEGIN
        DECLARE z INT;
        SET z = inOutParam + 1;
        SET inOutParam = z;
        SELECT inputParam;
        SELECT CONCAT('zyxw', inputParam);
    ENDI have tested the query in MySQL and the stored procedure does work correctly. The Java code successfuly runs the stored procedure, but the INOUT parameter always returns as 1. This behaviour indicates that when the stored procedure runs, inOutParam is set to 0, regardless of what value it is given in the Java code. Therefore, is the INOUT parameter fully supported? Maybe my Java code is incorrect?
    Thanks in advance for a response.

    I don't see anything obviously wrong with the code. That you are always getting 1 out, suggests the possibility that the input value isn't going in, is defaulting to 0 and 0+ 1 is being returned...
    As a guess, try doing:
    cStmt.setInt(2, 4);instead of:
    cStmt.setInt("inOutParam", 4);It could be that MySQL has some problems with "by name" parameters...
    Alternately, modify the stored procedure to put inOutParam into a table and see what value is being recieved...

  • Jdbc mysql bug?!?!

    Hi all,
    I'm using jsc and mysql in my webapp.
    I need to show full names in a listbox:
    I have a table with several columns, in particular I have name and surname.
    Somewhere I found a tutorial to modify sql query:
    it's quite simple, just to use CONCAT....
    If I run the query it works, but it does't name the result with alias I defined into the query... so I have no way to tell to my webapp to show this column.
    Has anyone experienced the same??
    I solved creating a view in my db and getting data from this view...

    Some else here reported a similiar "column alias ignored" type of issue not too long ago.
    They reverted to an earlier version of the mysql jdbc driver -
    connectorJ/version 5.X failed, version 3.1.XX worked.
    You can verify it's a JDBC driver bug by opening a view data window, enter "smd", a space, then your select statement, then run This will then show the metadata the driver provides. Does it show your column alias? If not, file a bug with MySQL.

  • Drop down menu for birthday, inserting into Mysql

    I have a registration form that inserts a new record into
    mysql.
    For the birthday, I have two spryselect dropdowns (month and
    day), and one spry textfield (year).
    Once the user submits the form, how can the selected values
    (month and day) be combined with the inputted year so mysql can
    accept it: YYYY-MM-DD.
    Here is my insert code. I tried concat but I don't think I
    did it right.
    if ((isset($_POST["MM_insert"])) &&
    ($_POST["MM_insert"] == "form1")) {
    $insertSQL = sprintf("INSERT INTO members (Username,
    Password, `First`, `Last`, Birthday, Address1, Address2, City,
    `State`, Zip, Phone, Email, Newsletter) VALUES (%s, %s, %s, %s, %s,
    %s, %s, %s, %s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['Username'], "text"),
    GetSQLValueString($_POST['Password'], "text"),
    GetSQLValueString($_POST['First_Name'], "text"),
    GetSQLValueString($_POST['Last_Name'], "text"),
    GetSQLValueString($_POST['Birthday'], $year.$month.$day),
    GetSQLValueString($_POST['Address1'], "text"),
    GetSQLValueString($_POST['Address2'], "text"),
    GetSQLValueString($_POST['City'], "text"),
    GetSQLValueString($_POST['State'], "text"),
    GetSQLValueString($_POST['Zip'], "int"),
    GetSQLValueString($_POST['Phone_Number'], "int"),
    GetSQLValueString($_POST['EMail_Address'], "text"),
    GetSQLValueString($_POST['Newsletter'], "text"));

    chris.cavage wrote:
    > Here is my insert code. I tried concat but I don't think
    I did it right.
    Assuming you have named the select elements and text field
    "month",
    "day", and "year", you need to add this somewhere near the
    top of the page:
    if (isset($_POST['month']) && isset($_POST['day'])
    isset($_POST['year'])) {
    $_POST['birthday'] =
    "{$_POST['year']}-{$_POST['month']}-{$_POST['day']}";
    } else {
    $_POST['birthday'] = 0;
    Then change this:
    > GetSQLValueString($_POST['Birthday'],
    > $year.$month.$day),
    to this:
    GetSQLValueString($_POST['Birthday'], "text"),
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS4",
    "PHP Solutions" & "PHP Object-Oriented Solutions"
    http://foundationphp.com/

  • How to insert data from JTable to mysql Table....

    hello everybody
    i need help about how to insert data from JTable to mysql table... i know about how to create Table model...facing problem about how to insert data from JTable to mysql table....any helping link or code ... ill be thankfulll....for giving me solution...

    table1.getValueAt(table1.getSelectedRow(),0)you are getting the value of a selected row... or if you want you can just use a loop..
    for(.....){
    table1.getValueAt(x,y);
    }I think you know INSERT STATEMENT.. here on it just string concat
    sample e.g. (This not insert)
    "delete from accrule " +
                    "where ruleid= " + tblRA.getValueAt(tblRA.getSelectedRow(),0)+
                    " and accountname='"+tblRA.getValueAt(tblRA.getSelectedRow(),1)+"'"

  • Function CONCAT on JPQL

    Hi everybody.
    I'm currently working on a J2SE application and i'm using JPA as persistence framework, it works very fine, but when I try to do a query with a function CONCAT it came with an error:
    +Caused by: Exception [TOPLINK-8025] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.EJBQLException
    Exception Description: Syntax error parsing the query [SELECT CONCAT(CONCAT(d.nombre, ' ', CONCAT(d.apellidoPaterno, ' ') d.apellidoMaterno)) FROM Datospersonales as d, Personaljuzgado as p WHERE p.idDatosPersonales = d.idDatosPersonales ], line 1, column 8: unexpected token [CONCAT].
    Internal Exception: line 1:8: unexpected token: CONCAT+
    The statement in MySQL that I'm trying to do is :
    +SELECT CONCAT(datospersonales.nombre, ' ', datospersonales.apellidoPaterno, ' ', datospersonales.apellidoMaterno )
    FROM datospersonales, personaljuzgado
    WHERE personaljuzgado.idDatosPersonales = datospersonales.idDatosPersonales;+
    Any help will be grateful, thanx a lot :D

    Oops, also JPQL BNF does not allow functions in the SELECT clause. Seems like a limitation of the Spec.
    As a workaround you could just select the fields back and build the string in Java. Otherwise you could create a native query, or use a TopLink ReportQuery and Expressions directly (which does support functions in the Select clause).

  • Can not get PK-FK in meta-Data of MySql....Help me pls.

    Hello Every one.
    I can not to get the PK and FK from Meta-Data Database of mysql-4.1.1a-alpha. Anyway I tried to do the
    followihg
    1. OS windows 2000 Pro.
    2. set configuration Script support InnoDB Table Type as the follow in my.ini file.
    [mysqld-nt]
    innodb_data_home_dir = C:\mysql\data
    innodb_data_file_path =\ibdata\ibdata1:2000M // in folder \data\ i was created folder ibdata
    3. I try to create data as reference in example java code and table :persons , shirt as the example in
    Create innodb table Type of mysql doc.
    4. the code test as following
    In the test code i can get the result only from method : getPrimarykey(...); only and the other method ,getExportedKeys, getImportedKey , getCrossReference the result in ResultSet is null.
    anyway, this code i can apply in the oracle db with change db driver .
    I wish the answer why? and the actually the second parameter of this parameter , as refer scheme name , the scheme name is ?
    Thank you
    import java.sql.*;
    public class testMeta {
    public testMeta() {
    ResultSet rs=null;
    String url = "jdbc:mysql://localhost:3306/testinnodb";
    Connection con = null;
    try{
    Class.forName("org.gjt.mm.mysql.Driver");
    }catch(ClassNotFoundException ex){
    System.out.println(ex.getMessage());
    try{
    con = DriverManager.getConnection(url,"root","rootpwd");
    prtS("getConnection complete");
    DatabaseMetaData metaData = con.getMetaData();
    Connection con2 = metaData.getConnection();
    String type[] = new String[1];
    type[0] = new String();
    prtS("*************** GET Schemas ***************");
    rs = metaData.getSchemas();
                   while(rs.next()){
    System.out.println("12345");
    prtS("TABLE_CAT" + " : " + rs.getString(0));
    prtS("TABLE_CAT" + " : " + rs.getString("TABLE_SCHEM "));
                   rs=null;
    prtS("*************** GET PRIMARY KEYS ***************");
    rs = metaData.getPrimaryKeys(con.getCatalog(),null,"persons");
    while(rs.next()){
    prtS("TABLE_CAT" + " : " + rs.getString("TABLE_CAT"));
    prtS("TABLE_SCHEM" + " : " + rs.getString("TABLE_SCHEM"));
    prtS("TABLE_NAME" + " : " + rs.getString("TABLE_NAME"));
    prtS("COLUMN_NAME" + " : " + rs.getString("COLUMN_NAME"));
    prtS("KEY_SEQ" + " : " + rs.getString("KEY_SEQ"));
    prtS("PK_NAME" + " : " + rs.getString("PK_NAME"));
                   rs=null;
    prtS("*************** GET Exported KEYS ***************");
    rs = metaData.getExportedKeys(con.getCatalog(),null,"shirt");
    while(rs.next()){
    prtS("FKCOLUMN_NAME" + " : " + rs.getString("FKCOLUMN_NAME"));
                   rs=null;
    prtS("*************** GET Imported KEYS ***************");
    rs = metaData.getImportedKeys(con.getCatalog(),null,"persons");
    while(rs.next()){
    prtS("PKTABLE_CAT" + " : " + rs.getString("PKTABLE_CAT"));
    rs=null;
    prtS("*************** GET CrossReference ***************");
    rs = metaData.getCrossReference(con.getCatalog(),null,"persons",con.getCatalog(),null,"shirts");
    while(rs.next()){
    prtS("PKTABLE_CAT" + " : " + rs.getString("PKTABLE_CAT"));
    }catch(SQLException ex){
    prtS(ex.getMessage());

    How i know the jdbc driver not compatible to this
    mechanismBy reading the documentation tthat comes with your driver. Recent versions of the MySQL JDBC driver do support the getExportedKeys/ImportegKeys methods but the table needs to be crated as InnoDB.
    So run the SQL command
    show table statusWhats under the Type column for your table? If it isn't InnoDB then this isn't going to work.
    If it is InnoDB but getExportedKeys/ImportegKeys still don't work then you haven't used the "foreign key" constraint in your "create table" command

  • Strange scenario,Oracle can not display the data in mysql correctly

    I use Heterogeneous Service+ODBC to achieve "oracle access mysql"(any other method?),and now i find Oracle can not display the data in mysql correctly:
    -------mysql------------
    mysql> create table tst(id int,name varchar(10));
    Query OK, 0 rows affected (0.00 sec)
    mysql> insert into tst values(1,'a');
    Query OK, 1 row affected (0.00 sec)
    mysql> select * from tst;
    ------------+
    | id | name |
    ------------+
    | 1 | a |
    ------------+
    1 row in set (0.00 sec)
    mysql> show create table tst\G
    *************************** 1. row ***************************
    Table: tst
    Create Table: CREATE TABLE `tst` (
    `id` int(11) DEFAULT NULL,
    `name` varchar(10) DEFAULT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8
    1 row in set (0.00 sec)
    -------------oracle ------------------
    SQL> select count(*) from "tst"@mysql;
    COUNT(*)
    49
    SQL> select * from "tst"@mysql;
    id
    1
    SQL> desc "tst"@mysql;
    Name Null? Type
    id NUMBER(10)

    You can make the following query on the result page:
    "select * from the_table where movietitle = ? and cinema = ?"
    then you set movietitle and cinema to those which the user selected. If the resultset contains more than 0 rows, that means the movie is available.
    Below is the sample code, it assumes you have a connection to the database:
    PreparedStatement stat = myConnection.prepareStatement("select * from the_table where movietitle = ? and cinema = ?");
    stat.setString(1, usersMovieTitleSelection);
    stat.setString(2, usersCinemaSelection);
    ResultSet res = stat.executeQuery();
    if (res.next()) {
    out.print("The movie is available");
    } else {
    out.print("The movie is not available");
    }Now just add that to your JSP page. Enjoy ! =)

Maybe you are looking for

  • Convert utf-8 to iso-8859-1

    Hello, sorry for my very bad english i use httpxmlrequest to answer a database and show resultin a div the string means utf-8 encoded by my javascript fonction and, of course, no result are found in the database. How can i convert the string to iso-8

  • Translations of SAP Script from English to Spanish

    Hi All, I need to do translate one of the SAP script from English to Spanish. Could anyone please help me how to achieve this? Thank you in anticipation.

  • Exchange project structure plan via EDI

    Hello, we try to exchange (part of) a project structure plan (and other project data) between two SAP R/3 systems (mandants) via EDI. Unfortunately, we have lots of problems with this. - We don't know if that's possible at all, as we didn't find a wa

  • What are the OS differences between mini, mini server and XServe?

    Hi, Apart from cpu speed disk size and memory, what are the differences between the mac mini and the mini server? What, if any, are the differences in the OS, software tools etc? Also, what are the differences between the OS in the mini, mini server

  • BW Number Range Buffer

    HI, We are facing performance issue and i would like to perform BW number range buffering. I used function module RSD_CUBE_GET to get the information on the dimension name. What i notice is the name of the dimension in BW Production and BW Developmen