Results 1 to 3 of 3

Thread: What does MAX(field_name) return when no data?

  1. #1
    Join Date
    Jul 2006
    Location
    Nottingham
    Posts
    2

    What does MAX(field_name) return when no data?

    I have a scenario where a SELECT MAX() query may not have any results.

    SELECT MAX(location_order) AS max_location_order
    FROM locations_data
    WHERE location_parent_id = '$new_location_insert_position_id'"

    If there are no items with an appropriate location_parent_id value, what value does max_location_order take?
    Null, 0 (zero) or unassigned?

  2. #2
    Join Date
    Jul 2006
    Posts
    19

    max value when no data in the table

    hi...

    if no data in the table... max(field_name) return the NULL value.

    By
    S.Ashokkumar
    PDI
    India.

  3. #3
    Join Date
    Jul 2006
    Location
    Nottingham
    Posts
    2
    Thank you for your reply.
    What I mainly failed to ask is...
    Is this behaviour the same in all reasonably current versions of MySQL?

Posting Permissions

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