Avatar of XK8ER
XK8ERFlag for United States of America asked on

mysql structure

Hello,
I have this mysql structure that its working fine for me and very simple..
I would like to know if its possible to create something so that it doesn't allow duplicates on (itockSymbol with iwhen) which is a timestamp

for example there is an insert USD and 1394647007306
and again another insert insert USD and 1394647007306 but dont allow it as it is a dup.
but if its AUD and 1394647007306 then its okay.
how can I do this?

CREATE TABLE IF NOT EXISTS `EURJPY` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `itockSymbol` varchar(40) DEFAULT NULL,
  `iwhen` varchar(20) DEFAULT NULL,
  `ibuyValue` varchar(20) DEFAULT NULL,
  `isellValue` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
)  ;

Open in new window

MySQL ServerDatabasesMicrosoft SQL Server

Avatar of undefined
Last Comment
Dan Craciun

8/22/2022 - Mon
Dan Craciun

Create an unique key on (itockSymbol, iwhen)

HTH,
Dan
ASKER
XK8ER

like this?

alter table EURJPY add unique index(itockSymbol, iwhen);

Open in new window

Dan Craciun

ALTER TABLE EURJPY ADD UNIQUE (itockSymbol, iwhen);
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER
XK8ER

it does the exact same thing
ASKER CERTIFIED SOLUTION
Dan Craciun

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question