SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with rounding up fields.

    Hello friends, I have two questions and hope someone could suggest something.

    1. Is is possible to round up specified fields in mysql database columns? If it is how can this be achieved?

    2. I want to round up 4 fields in the query below so that the comparison on those 4 fields would be without errors since the two fields do not have the exact number of significant figures. Rounding these fields should checkmate error. How can I do it in the query below on the latitude and server_latitude, longitude and server_longitude.

    I want to simply add the rounding up to the query which is working already. Thanks for your help. Below is the query:

    UPDATE (
    SELECT r.rmc_time, r.rmc_date, r.latitude, r.longitude, IF(s.server_rmc_time IS NULL AND s.server_rmc_date IS NULL AND s.server_latitude IS NULL AND s.server_longitude IS NULL, 'mobile', 'both') c FROM rmc_raw_data r
    LEFT JOIN server_log_data s
    ON r.rmc_time = s.server_rmc_time AND r.rmc_date = s.server_rmc_date AND r.latitude = s.server_latitude AND r.longitude = s.server_longitude
    UNION
    SELECT s.server_rmc_time, s.server_rmc_date, s.server_latitude, s.server_longitude, IF(r.rmc_time IS NULL AND r.rmc_date IS NULL AND r.latitude IS NULL AND r.longitude IS NULL, 'server', 'both') c FROM rmc_raw_data r
    RIGHT JOIN server_log_data s
    ON r.rmc_time = s.server_rmc_time AND r.rmc_date = server_rmc_date AND r.latitude = server_latitude AND r.longitude = s.server_longitude
    ) t
    LEFT JOIN rmc_raw_data r1
    ON r1.rmc_time = t.rmc_time AND r1.rmc_date = t.rmc_date AND r1.latitude = t.latitude AND r1.longitude = t.longitude
    LEFT JOIN server_log_data s1
    ON s1.server_rmc_time = t.rmc_time AND s1.server_rmc_date = t.rmc_date AND s1.server_latitude = t.latitude AND s1.server_longitude = t.longitude
    SET
    r1.data_source = c, s1.data_source = c;


    Regards

    Paul

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by paul_paisley View Post
    1. Is is possible to round up specified fields in mysql database columns? If it is how can this be achieved?
    yes, it is possible, and it is achieved with the ROUND function
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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