Category Archives: SQL

How to use SQL where like in()

SELECT column FROM table WHERE column LIKE ‘%like1%’ OR column LIKE ‘%like2%’ OR column LIKE ‘%etc2%’ can be written simply as SELECT column FROM table WHERE column REGEXP ‘like1|like2|etc’

Posted in MySQL, SQL | Tagged , , | Leave a comment

How to set a MySQL Table AUTO_INCREMENT

To start with an AUTO_INCREMENT value other than 1, you can set that value with CREATE TABLE or ALTER TABLE, like this: mysql> ALTER TABLE tbl AUTO_INCREMENT = 100;

Posted in MySQL, SQL | Tagged | Leave a comment

How to Remove a MySQL Table constraint

ALTER TABLE `attributes` DROP FOREIGN KEY `attributes_ibfk_1`; MySQL ERROR 1005 (HY000): Can’t create table ‘Table.frm’ (errno: 150).  Here’s the solution. Example: ALTER TABLE `race` DROP FOREIGN KEY `race_ibfk_1`; ALTER TABLE `race` ADD CONSTRAINT `race_ibfk_1` FOREIGN KEY (`specieId`) REFERENCES `specie` (`specieId`) … Continue reading

Posted in MySQL, SQL | Tagged , | Leave a comment

How to Create Database and Add User To It

Here are the SQL commands: create database newdb; grant CREATE,INSERT,DELETE,UPDATE,SELECT on newdb.* to newuser@localhost; SET PASSWORD FOR ‘newuser’@'localhost’ = password(‘newuserpass’); – or – SET PASSWORD FOR ‘newuser’@'localhost’ = old_password(‘newuserpass’); flush privileges;

Posted in Database, MySQL, Programming, SQL | Tagged , | Leave a comment