Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2016
    Posts
    2

    Unanswered: Syntax Error Newbie

    Hello,

    I am new to mysql and I am getting an error when trying to perform a query, I have a table with a list of employees and their salaries and I am supposed to get a list of the employees which last name ends in a vowel and apply a percent to the salary. I have searched in my book but I cannot find a solution.


    Code:
    	SELECT concat(`fname`,' ', `lname`) as 'Full Name',
    		(`salary` * 0.012) as 'Tax'
    	FROM `employee`
    	WHERE (`'lname`) IN ( SELECT RIGHT(`lname`,1) as 'lLetter'
    			FROM `employee`
    			WHERE `lLeter` IN ('a', 'e', 'i', 'o', 'u'));
    	ORDER BY `lname`;
    Thanks a lot in advance

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    And the error message is? Mysql usually tells you where abouts it lost the the plot. Im highly suspicious of your where clause

    https://www.google.co.uk/webhp?sourc...haracter&cns=0
    Last edited by healdem; 02-07-16 at 15:29.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Feb 2016
    Posts
    2
    Thanks a lot for your reply healdem,

    I am not sure what I was thinking I though of creating a temporary table on the fly with an additional column with the ending letters and then make another select based on that.

    I have updated the query to this and it's working
    Code:
    SELECT concat(`fname`,' ', `lname`) as 'Full Name',
    	(`salary` * 0.012) as 'Tax'
    FROM `employee`
    WHERE (RIGHT(`lname`,1) IN ('a', 'e', 'i', 'o', 'u'));
    ORDER BY `lname`;
    Thanks a lot for the help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •