user3387522
user3387522

Reputation: 127

preferred way to make a unique column id in sql database

Hi all I just wanted to know if there is a preferred way of creating a unique id within a sql table so far I have tried Auto-increment of the number and this started to cause problems in future planning, so I have thought about using the php Rand() and then turning this into a string and then insert this into a database but there is a higher chance off two numbers being the same with the amount of data that will be within the database.

I was just wondering if there any suggestions of a preferred way to create a unique column_id im open to all suggestions there is just a couple things the id needs to be easy enough to be used within other tables within inner joins and left outer joins and also used a file name as well for a download section and a upload section.

Upvotes: 1

Views: 111

Answers (2)

MikkaRin
MikkaRin

Reputation: 3084

use GUID

string com_create_guid ( void )

Upvotes: 2

SagarPPanchal
SagarPPanchal

Reputation: 10121

<?php
 echo uniqid();
?> 

Description

Upvotes: 1

Related Questions