MySQL Strings Segmentation

SUBSTRING_INDEX(str, delim, count) str: the string to be split. delim: the delimiter. count: the position of the delimiter. A positive number means extract from left to right, a negative number means extract from right to left. For example: SELECT SUBSTRING_INDEX('100-200-300-400', '-', 1); — output: '100' SELECT SUBSTRING_INDEX('100-200-300-400', '-', 2); — Read more…

MySQL basic syntax

Database and Table · Create Database CREATE DATABASE <database name>; CREATE DATABASE shop; · Create Table CREATE TABLE <table name> (<column name> <data type> <constrains>, <column name> <data type> <constrains>, …, <constrains of the table>,<constrains of the table>,…); CREATE TABLE product (id CHAR(4) NOT NULL, name VARCHAR(100) NOT NULL, price Read more…