Questions tagged as 'mysql'

1
answer

Problem with logic when using LEFT JOIN

In my system, there is a system of postings and another system of friendships. Here is the structure of the tables: posts : id | usuario | conteudo | data | hora Friendships : id | usuario1 | usuario2 | status And I'm us...
asked by 21.11.2015 / 16:50
1
answer

Translation of MySQL code for PostgreSQL [closed]

I need to convert a MySQL page into PostgreSQL commands, but I have already reviewed the internet looking for similar commands and PostgreSQL syntax, and I did not succeed. Some commands do not exist for PostgreSQL and are declared together w...
asked by 17.11.2015 / 17:27
4
answers

Different ways to count record numbers in MySQL

There's a difference in performance if you do: //seleciona todos os itens da tabela $cmd = "SELECT * FROM produtos"; $produtos = mysql_query($cmd); //conta o total de itens $total = mysql_num_rows($produtos); instead of executing a query:...
asked by 23.01.2015 / 14:42
1
answer

MySQL sort too slow for results with many records

I have two tables, the first one is used to group the data of the second with some information about the set, in order to facilitate the pagination of the contents. Table 1: - id INT(11) NOT NULL UNSIGNED AUTO_INCRE...
asked by 30.04.2016 / 02:12
2
answers

Search system listing error with pagination

When I query, I get the following result [image1] When clicking to go to page 2, I get the following result [image2] That is, on page "1" everything works with the total results displayed (10) and total links (2), but when going to page "2...
asked by 04.09.2015 / 00:33
1
answer

PHP - Make 3 INSERT on different tables with relationship between them

I would like your endorsement. I need to do 3 INSERT at once. But I also need to get the last ID of each table to do the relationship of the tables. Is this correct, to do this? if($_GET['operacao'] == 'addPrimeiroCadastro'){...
asked by 18.12.2015 / 02:59
1
answer

Mysqli bind with an array of values

I have a code in PDO and I need to convert this code to mysqli, at this moment I have something like that: $sql = "SELECT * from tabela where nome = ? AND idade = ? AND outro = ?"; $stmt = $core->conn->prepare($sql); $bindArray = array...
asked by 04.12.2015 / 12:56
2
answers

What is the difference between SET and ENUM in MySQL?

What are the differences between SET and ENUM in MySQL? And in which situations are both applied in the best way?     
asked by 28.09.2017 / 16:35
2
answers

Divide column into multiple tables

I want to save a set of information about movies in a database but I have a question, should I organize the genres in a column (example below). Database: MySQL 5.6.21 Engine: innoDB Or arrange the genres in a separate table and use...
asked by 01.04.2015 / 17:17
3
answers

How to round a number to the highest value in Mysql?

I was doing some testing in MySQL and then came the need to have to round a number to the largest. It would be something like: if($numero == 1.5){ $numero = 2; } Although I could do this, I wanted to avoid making if / else...
asked by 13.09.2017 / 16:16