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

    Join Date
    Feb 2013
    Posts
    13
    Rep Power
    0

    Query to display balance x 5%


    I am a new user of MYSQL 6.0 & am trying to write a query that will display the available balance in various accounts if 5% were added to the available balance. When I input the following nothing came up on the screen, but I didn't get an error message either:

    Update account
    set avail_balance = avail_balance*1.05
    where product_cd = 'CD';

    I know there's something missing but can't figure out what.
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,245
    Rep Power
    9400
    Is it MySQL which you said in your post (which doesn't have a version 6 by the way) or MS SQL which is where you've posted this thread?

    Regardless, you did an UPDATE query. It won't return anything, it just does an action. You have to SELECT the data again to see the changes.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    13
    Rep Power
    0

    Display balance & type of product


    Originally Posted by requinix
    Is it MySQL which you said in your post (which doesn't have a version 6 by the way) or MS SQL which is where you've posted this thread?

    Regardless, you did an UPDATE query. It won't return anything, it just does an action. You have to SELECT the data again to see the changes.

    OK. I added SELECT avail_balance FROM account, but I also need to see that it's only pulling from accounts with the product_cd of 'CD'. I tried a WHERE statement, but got an error.
  6. #4
  7. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,706
    Rep Power
    1959
    Please post the error message and the SELECT statement which returned the error.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    13
    Rep Power
    0
    Error Code: 1064
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Select product_cd
    from account

    Select product_cd
    from account
    where product_cd = 'CD';
  10. #6
  11. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,262
    Rep Power
    4279
    Originally Posted by bstar
    Select product_cd
    from account
    where product_cd = 'CD';
    you don't even have to run this query to know what the result is going to be

    either there will be nothing returned, or there will be one or more rows like this --

    product_cd
    ----------
    CD
    CD
    CD
    CD
    ...

    how useful is that?

    by the way, where exactly are you running this query
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    92
    Rep Power
    3
    try
    SELECT * FROM account WHERE product_cd = 'CD';

IMN logo majestic logo threadwatch logo seochat tools logo