fishcracker
fishcracker

Reputation: 2529

remove dash of UUID generated directly on MySQL

I generate UUID using INSERT INTO tbl1 (key, val) VALUES (UUID(), :value) directly on MySQL using PDO. I don't have any idea how to remove those - (dashes) on MySQL side, on PHP side I can simply remove it using str_replace().

Upvotes: 10

Views: 14291

Answers (2)

Alan Fullmer
Alan Fullmer

Reputation: 1236

REPLACE(UUID(),'-','')

You don't need the UNHEX, just simply replace the hyphens.

Upvotes: 25

triclosan
triclosan

Reputation: 5724

to get decimal value for placing into some integer field use

UNHEX(REPLACE(UUID(),'-',''))

Upvotes: 1

Related Questions