Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8926119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:53:24+00:00 2026-06-15T07:53:24+00:00

I have a view over three tables. It has 6 columns as follows: ID

  • 0

I have a view over three tables. It has 6 columns as follows:

ID | NAME | PRINCIPAL_ID | DESCRIPTION | GROUP_ID | TYPE

As I’m using hibernate to retrieve data from database, I had to put the ID column in this view. The problem is, I cannot generate a unique ID which seems to be necessary for hibernate to correctly load the data.

How can I have a unique ID for every row in this view?

Maybe this can help, I’m not sure: The combination of PRINCIPAL_ID and GROUP_ID can make a unique ID. All these three are Long.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:53:26+00:00Added an answer on June 15, 2026 at 7:53 am

    UPDATE: When you insist to have it as a number, create your view like this:

    SELECT
    (@rownum:=@rownum + 1) AS rownumber,
    yourTable.*
    FROM
    yourTable
    , (SELECT @rownum:=0) r
    

    But that’s really it – no more other possibilities. Cast rownumber as long like I said in comments, if it really, really has to be long.

    Alternatively in a procedure:

    DELIMITER $$
    CREATE PROCEDURE selectFromWhatever()
    BEGIN
    SELECT
    (@rownum:=@rownum + 1) AS rownumber,
    yourTable.*
    FROM
    yourTable
    , (SELECT @rownum:=0) r;
    END $$
    DELIMITER ;
    

    Then get result with

    CALL selectFromWhatever()
    

    Original answer:

    From the MySQL manual:

    UUID()

    Returns a Universal Unique Identifier (UUID) generated according to
    “DCE 1.1: Remote Procedure Call” (Appendix A) CAE (Common Applications
    Environment) Specifications published by The Open Group in October
    1997 (Document Number C706,
    http://www.opengroup.org/public/pubs/catalog/c706.htm).

    A UUID is designed as a number that is globally unique in space and
    time. Two calls to UUID() are expected to generate two different
    values, even if these calls are performed on two separate computers
    that are not connected to each other.

    A UUID is a 128-bit number represented by a utf8 string of five
    hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format:

    The first three numbers are generated from a timestamp.

    The fourth number preserves temporal uniqueness in case the timestamp value loses monotonicity (for example, due to daylight
    saving time).

    The fifth number is an IEEE 802 node number that provides spatial uniqueness. A random number is substituted if the latter is not
    available (for example, because the host computer has no Ethernet
    card, or we do not know how to find the hardware address of an
    interface on your operating system). In this case, spatial uniqueness
    cannot be guaranteed. Nevertheless, a collision should have very low
    probability.

    Currently, the MAC address of an interface is taken into account only on FreeBSD and Linux. On other operating systems, MySQL uses a
    randomly generated 48-bit number.

    mysql> SELECT UUID();
    -> ‘6ccd780c-baba-1026-9564-0040f4311e29’

    Warning

    Although UUID() values are intended to be unique, they are not
    necessarily unguessable or unpredictable. If unpredictability is
    required, UUID values should be generated some other way. Note

    UUID() does not work with statement-based replication.

    Another way would be to use CONCAT() to build your unique ID.

    SELECT CONCAT(PRINCIPAL_ID, '-', GROUP_ID) AS myUniqueID
    FROM yourTable
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list view with over 100 items. Each of these items show
I need to have a new view(w/ ViewController) added over the top of another.
I have a subview over my UITable that is used as a busy view.
I have a view which generates a number of columns which I want to
I have a view defined in SQL server 2008 that joins 4 tables together.
I have a MySQL database that has over 9000 rows with 10 fields. It
Using the Stack Overflow public data dump, I've created three simple tables: Questions (Question_Id,
I'm trying to create a view that's going to have 3 separate tables on
We have a customer very large table with over 500 columns (i know someone
I have a View Controller that have a tableView inside it which has different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.