MySQL Forums
Forum List  »  Spanish

PRIMARY KEY con varias columnas
Posted by: Marco Rios
Date: April 08, 2019 02:39PM

Que tal,
estoy tratando de crear una LLAVE PRIMARIA usando la combinación de 2 columnas de una tabla usando la siguiente consulta:

ALTER TABLE proturs_test.contr_hoteles_inventario 
	ADD PRIMARY KEY(CONCAT(LPAD(id,6,'0'),LPAD(DATEDIFF(fecha,'1980-01-01'),5,'0'))) NOT NULL
;

Pero al ejecutarla, me marca que existe un error.

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LPAD(id_hotel,6,'0'),LPAD(DATEDIFF(fecha,'1980-01-01'),5,'' at line 2

Thanks in advance for your valuable help.

Acer LENOVO G450
CPU: Pentium(R) Dual-Core CPU T4400 @ 2.20GHz × 2
RAM: 4GB
Graphics: Intel GM45
OS: UBUNTU 18.04.4 LTS 64bits
GNOME 3.28.2
--
Best regards
Marco
Mexico City, Mexico

Options: ReplyQuote


Subject
Views
Written By
Posted
PRIMARY KEY con varias columnas
780
April 08, 2019 02:39PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.