Questions tagged as 'mysql'

3
answers

Is it a good practice to use composite keys as a primary key? [duplicate]

I do not have much knowledge in database design. I have tried to hone myself better and am looking for best practices on how to create and structure tables. I currently create binding tables and combine the ID's of each table by turning the...
asked by 08.08.2016 / 16:54
2
answers

Displaying the last 30 days of a query

I'm trying some alternatives to show only the records of the last 30 days, but I could not make it work, the query I have looks like this: SELECT comunidade.descricao AS nomeunidade ,comcargo.descricao AS nomecargo ,comcolaborador....
asked by 03.02.2017 / 18:31
2
answers

MySQL Auto increment number pair

I have a MySQL database with a id field that is AUTO_INCREMENT . You have some configuration problem in it because at the time of making the auto increment it is coming out exactly in this sequence: ID: 2 ID: 12 ID: 22 ID: 32 ID: 42...
asked by 10.02.2017 / 14:59
2
answers

What is the difference between an empty string and NULL in SQL?

What's the difference if you store a string as NULL or empty in SQL? How can these two behave when I make a SELECT , or INSERT with value '' in that column that is of type varchar ? If I leave the de...
asked by 13.01.2017 / 15:58
2
answers

Convert row to column

I have a field called "Shift" of type STRING , storing data in MySql like this: '1,2,3,4,5,6,7,8,9' I need this string to transpose (transpose) into a single column (in this case, it would be the inverse of what GROUP_CONCAT...
asked by 04.03.2014 / 05:54
2
answers

Get AUTO_INCREMENT value from a table

I want to get the last record entered in a database table, that is, the value of AUTO_INCREMENT of the table, I tried using: SELECT MAX(id) as max FROM people It works, but if I do not have any records in the table it will return...
asked by 06.07.2016 / 19:10
2
answers

What is undescore for "_" in MYSQL LIKE?

In a previous question regarding LIKE in MYSQL , Should I avoid injecting"% "into a query where I used" LIKE "? , a question arose of _ (undescore) can be used in the LIKE operator. I've used the % a lot, bu...
asked by 17.09.2015 / 19:14
4
answers

Difference between prepare () and query ()?

I was doing select on a table. I went to see the result, returned false. Then I used query and it worked. What's the difference between the two? <?php $query = DB::getConn()->prepare('select * from tabela where id...
asked by 14.10.2015 / 22:37
1
answer

How to display error when doing query?

I have the following problem, this query is not inserting data into the database: $inserir2 = mysqli_query($link, "INSERT INTO cliques (emailusuario, brasil, lucrobrasil, portugal, lucroportugal, suica, lucrosuica, belgica, lucrobelgica, austr...
asked by 21.07.2016 / 00:24
3
answers

Query two tables in Mysql

My situation is this: I have several tables that have some information in common, such as UNIT. In one of these tables I have all my units and I need to check if this same UNIT also exists in another table, and if there is, display the inform...
asked by 24.11.2014 / 19:11