Skip to content

Instantly share code, notes, and snippets.

View LeandroLS's full-sized avatar
🎯
Focusing

Leandro L. LeandroLS

🎯
Focusing
View GitHub Profile
@LeandroLS
LeandroLS / indicesmysql1.sql
Created June 21, 2017 15:20
Gist post indices-mysql
SELECT
*,
(SELECT
COUNT(l2.data_de_lancamento)
FROM
livros AS l2
WHERE
l2.data_de_lancamento = l.data_de_lancamento) AS vendas_anteriores
FROM
livros AS l;
@LeandroLS
LeandroLS / indicesmysql2.sql
Created June 21, 2017 15:22
Gist post indices-mysql
CREATE index indice_por_lancamento ON livros(data_de_lancamento);
@LeandroLS
LeandroLS / indicesmysql3.txt
Created June 22, 2017 01:14
Gist post indices-mysql
SELECT COUNT(id) FROM livros;
+-----------+
| COUNT(id) |
+-----------+
| 20000 |
+-----------+
1 row in set (0.00 sec)
@LeandroLS
LeandroLS / GROUP_CONCATnoMySQL
Created June 24, 2017 17:05
Post GROUP_CONCAT()noMySQL
SELECT nome FROM CONTAS;
+-----------------------------+
| nome |
+-----------------------------+
| Salario |
| Rendimento de investimentos |
| Recebimento de aluguel |
| Conta de água |
| Conta de luz |
| Jogos da Steam |
@LeandroLS
LeandroLS / GROUP_CONCATnoMySQL2
Created June 24, 2017 17:10
Post GROUP_CONCAT() no MySQL
SELECT GROUP_CONCAT(nome) FROM contas;
+-------------------------------------------------------------------------------------------------------+
| GROUP_CONCAT(nome) |
+-------------------------------------------------------------------------------------------------------+
| Salario,Rendimento de investimentos,Recebimento de aluguel,Conta de água,Conta de luz,Jogos da Steam |
+-------------------------------------------------------------------------------------------------------+
@LeandroLS
LeandroLS / GROUP_CONCATnoMySQL3
Created June 24, 2017 17:37
Post GROUP_CONCAT()noMySQL
SELECT contas.nome AS conta, classificacao.nome AS classificacao FROM contas INNER JOIN classificacao ON classificacao.id = contas.id_classificacao;
+-----------------------------+---------------+
| conta | classificacao |
+-----------------------------+---------------+
| Salario | receita |
| Rendimento de investimentos | receita |
| Recebimento de aluguel | receita |
| Conta de água | despesa |
| Conta de luz | despesa |
| Jogos da Steam | despesa |
@LeandroLS
LeandroLS / GROUP_CONCATnoMySQL4.sql
Created June 24, 2017 17:51
Post GROUP_CONCAT() no MYSQL
SELECT
GROUP_CONCAT(contas.nome) AS contas,
classificacao.nome AS classificacao
FROM
contas
INNER JOIN
classificacao ON classificacao.id = contas.id_classificacao
GROUP BY classificacao.nome;
+------------------------------------------------------------+---------------+
@LeandroLS
LeandroLS / alterando-sql-mode.sql
Created June 27, 2017 15:40
Post Alterando sql mode
set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
@LeandroLS
LeandroLS / input-mesmo-nome.html
Last active July 6, 2017 00:00
Post inputs mesmo nome
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Teste</title>
<script src="jquery-3.2.1.js"></script>
</head>
<body>
<form id='form' action="teste.php" method="POST">
<input type="text" name="nome" value='nome1'>
@LeandroLS
LeandroLS / input-mesmo-nome2.html
Created July 6, 2017 00:16
Post inputs mesmo nome
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Teste</title>
<script src="jquery-3.2.1.js"></script>
</head>
<body>
<form id='form' action="teste.php" method="POST">
<input type="text" name="nome[]" value='nome1'>