mysql combination of multiple columns code example

Example 1: how to select multiple columns from different tables in mysql

-- MySQL 
-- t1 = table1
-- dt2 = column of table
SELECT t1.dt2, t2.dt4, t2.dt5, t2.dt3 #get dt3 data from table2
FROM table1 t1, table2 t2 -- Doesn't need to have t1, or t2
WHERE t1.dt2 = 'asd' AND t2.dt4 = 'qax' AND t2.dt5 = 456

Example 2: mysql unique two columns

CREATE TABLE IF NOT EXISTS cliente (
	id bigint primary key auto_increment,
    nome varchar(100) not null,
    email varchar(100) not null unique,
    senha varchar(255) not null,
    documento varchar(50) not null unique,
    dataCadastro date not null
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;

Tags:

Sql Example