Archive | MYSQL RSS feed for this section

Generate Slug URL in MySQL

A slug is a short name using human-readable keywords to identify a web page. For example, in the following URL. example.com/schools/new-york-art-school the slug is new-york-art-school. This post shows how to automatically generate slug using SQL in MySQL. Suppose we have a table schools a field name, and we wish to generate a slug for each […]

Continue Reading ·
post-author

Date Converter Date Format yyyy-mm-dd PHP to MYSQL

//DB = 2013-03-14 //Setear en la base de datos $birthday = $this->request->post(’birthday_y’) . "-" . $this->request->post(’birthday_m’). "-". $this->request->post(’birthday_d’);           $rs_user->birthday = date("Y-m-d", strtotime($birthday));             $rs_user->save(); //Getter de la base de datos //DB = 2013-03-14 $dateb = explode("-", $rs_user->birthday); $b_year     = $dateb[0]; $b_month    = […]

Continue Reading ·
post-author

Table is marked as crashed and should be repaired

Error frecuente en bases de datos MYSQL, se puede solucionar este problema de dos maneras, solo ingresa al phpmyadmin y ejecuta una de estas dos secuencias. mysqlcheck –auto-repair base_de_datos <table_name>; repair table <table_name>; En un sitio web Joomla puede dar este mensaje en la web: Table ‘./codigoag_gamma/jos_session’ is marked as crashed and should be repaired" […]

Continue Reading ·
post-author

MySql : Update Campaign

UPDATE cmg_campaign SET start_date= adddate(start_date,60); UPDATE cmg_campaign SET finish_date= adddate(start_date,60);

Continue Reading ·
post-author

Mysql set decimal value if null

Actualizar campo decimal con un valor determinado en los casos que sea NULL UPDATE `pro_table` SET `weight`=’1000.00′ WHERE weight IS NULL UPDATE `pro_table` SET `width`=’50.00′ WHERE width IS NULL UPDATE `pro_table` SET `height`=’10.00′ WHERE height IS NULL UPDATE `pro_table` SET `depth`=’50.00′ WHERE depth IS NULL

Continue Reading ·
post-author

MYSQL – Limpiar enter en campo de tabla

UPDATE product SET summary=REPLACE(summary,’\n’,”)

Continue Reading ·
post-author

mysql : Cannot truncate a table referenced in a foreign key constraint

ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint (mytest.instance, CONSTRAINT instance_ibfk_1 FOREIGN KEY (GroupID) REFERENCES mytest.mygroup (ID)) SET FOREIGN_KEY_CHECKS=0; TRUNCATE table1; TRUNCATE table2; TRUNCATE table3; SET FOREIGN_KEY_CHECKS=1;

Continue Reading ·
post-author