Daan
Daan

Reputation: 23

How do I insert a record with a mysql SET type?

I wanted to ask how I insert a record with the mysql SET type. Lets assume the following table:

user_id   
int(8)

and

user_rights
set('conversation','offer','turnover','financial','admin');

How would my INSERT query be?

Thanks in advance

Upvotes: 0

Views: 110

Answers (2)

zessx
zessx

Reputation: 68790

Use single quotes around your choices (doc). You can set multiple choices :

INSERT INTO users(user_id, user_rights) VALUES 
(1, 'conversation,offer,turnover,financial,admin'),
(2, 'conversation,financial'),
(3, 'conversation'),
(4, 'conversation,offer,financial');

Upvotes: 4

Thibault
Thibault

Reputation: 1596

Here is an example :

INSERT INTO yourTable SET user_id=7, user_rights='admin';

See INSERT documentation.

Upvotes: 2

Related Questions