#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Posts
    3
    Rep Power
    0

    Unhappy SAMS Teach yourself SQL in 24 hours


    Afternoon all

    I am new to this forum and sort of new/intermediate to SQL. I am brushing up on my SQL programming skills , doing exercises from SAMS Teach yourself SQL book, on a Fedora 19 computer (using MariaDB 5.5.34) . Up to Chapter 10, I was able to complete all the exercises but ran into some issues in Chapter 11 with the three functions, LTRIM, RTRIM,DECODE. Every time I try to run an SQL statement with any of these three functions in the statement, I get the same error message as in the cut and paste below:

    MariaDB [SAMS_24_Hours]> SELECT POSITION, RTRIM(POSITION,'ER') FROM EMPLOYEE_PAY_TBL;
    ERROR 1582 (42000): Incorrect parameter count in the call to native function 'RTRIM'

    The table contents is listed as follows :
    MariaDB [SAMS_24_Hours]> SELECT * FROM EMPLOYEE_PAY_TBL;
    +-----------+---------------+------------+----------+-----------------+----------+---------+
    | EMP_ID | POSITION | DATE_HIRE | PAY_RATE | DATE_LAST_RAISE | SALARY | BONUS |
    +-----------+---------------+------------+----------+-----------------+----------+---------+
    | 213764555 | SALES MANAGER | 1994-08-14 | NULL | 1999-08-01 | 30000.00 | 2000.00 |
    | 220984332 | SHIPPER | 1996-07-22 | 11.00 | 1999-07-01 | NULL | NULL |
    | 311549902 | MARKETING | 1989-05-23 | NULL | 1999-05-01 | 40000.00 | NULL |
    | 313782439 | SALESMAN | 1997-06-28 | NULL | NULL | 20000.00 | 1000.00 |
    | 442346889 | TEAM LEADER | 1990-06-17 | 14.75 | 1999-06-01 | NULL | NULL |
    | 443679012 | SHIPPER | 1991-01-14 | 15.00 | 1999-01-01 | NULL | NULL |
    +-----------+---------------+------------+----------+-----------------+----------+---------+
    6 rows in set (0.00 sec)

    Any suggestions would be appreciated. If I find a solution on my own, I will post it here in case anyone of you has a similar problem

    Clived
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,173
    Rep Power
    4274
    two things

    first, mariaDB is a replacement engine for mysql, so your thread really belongs in the mysql forum, not the microsoft sql server forum -- i've moved it for you

    second, look up the RTRIM function in the mysql manual, to see exactly how many paramters it expects

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Posts
    3
    Rep Power
    0
    Thanks for your response, Rudy, Appreciate your moving my message into the right forum. I read the manual regarding number of parameters the function expects, not too clear on that, I'll run it over again today

    Thanks
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,173
    Rep Power
    4274
    Originally Posted by Clived
    I read the manual regarding number of parameters the function expects, not too clear on that, I'll run it over again today
    in brief, RTRIM takes only one parameter, and trims only spaces

    you want the verbose TRIM instead --
    Code:
    TRIM(TRAILING 'ER' FROM position)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Posts
    3
    Rep Power
    0

    Smile


    Wow, Rudy

    Thanks for your help, and that worked The example on Page 178 of Teach yourself SQL in 24 hours specified the code in my original post, but did NOT say as to whether this code was or was not compatible in MySQL (MariaDB).

    I really appreciate your help, Rudy, thanks

IMN logo majestic logo threadwatch logo seochat tools logo