Hi to all,
I created the following table
---------------------------------

create table publisher(name varchar(20), city varchar(20))

---------------------------------

I want to put following constraint, 'name is having unique with city taken only from 'mumbai', 'pune', 'nasik', 'panji''. I know about unique constraints with name. I searched many about constraint with city, but i don't get it till now. Will you please help me about constraint. I used 'BETWEEN' constraint, but it failed. What should I do?

If the field may only have four values, use an enum type.

create table publisher(name varchar(20), city enum('mumbai','pune','nasik','panji'))

hi......smantscheff.
i tried on ur solution, but it doesn't work. Plz, help me in different way.

What the hell do you mean with "doesn't work" ?

i means, sql server doent't support 'enum' type.

This here is a MySQL forum.

I know, this is mysql forum. I wrongly put this question in this forum. but i want the output in 'MS SQL Server'.


Thanks & regerds,
Pooja.

Create a lookup table for cities and link your publisher table to it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.