Questions tagged as 'sql-select'

8
answers

Giving a "SELECT" before an "INSERT" is a safe way of not having duplicate records?

I have a table with a codigo column. I can not set it as primary key. On a system that receives many notifications before it checks with a SELECT to see if that code already exists in the table. If it does not exist it gives INS...
asked by 16.01.2014 / 16:39
2
answers

What is the difference between where and having?

Doing some testing on a database in MySQL, I realized that: SELECT * From client WHERE uuid = '1kvsg4oracxq' returns the same result as: SELECT * From client HAVING uuid = '1kvsg4oracxq' What exactly is the difference between where...
asked by 09.06.2017 / 21:06
3
answers

How to use the result of a select to mount another?

I've mounted a select that concatenates a String. I want to use the result of this select in another select SELECT * FROM (SELECT CONCAT('caminho da tabela') AS caminho FROM tabela) AS result Can you do it? How can I use it?     
asked by 06.01.2016 / 16:31
1
answer

Compare COUNT of two tables

I have two tables and should I return the table total with more data, I'm doing this: SELECT CASE WHEN ((select count(*) as 'familiar' from tb.familiar)) > ((select count(*) as 'personal' from tb.personal))...
asked by 19.10.2016 / 17:54
5
answers

Remove letters and special characters in a select

I have in my table the document field with the following data: How do I select only the numbers of these records by removing the letters and special characters? DOCUMENTO CPF-12345698-35 CPF=05604968-34 CPF-:033369328-32 CPF-056904968-31...
asked by 16.05.2014 / 15:10
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
3
answers

Subtract date and display in YEARS, MONTHS and DAYS

DBMS: MySQL Problem: How do I return the subtract of the current date with a specific date and return the value in YEARS, MONTHS and DAYS in a query? Example: DADOS DataAdmissao dataAtual 2010-04-07 2014-06-27 (este dado não está...
asked by 27.06.2014 / 21:33
1
answer

Combination of 4 numbers in MySQL

DBMS: MySql Problem: List all the possibilities of combinations between the numbers "1,2,3,4", so that they do not repeat between them. Example: 1 2 3 4 12 13 14 21 23 24 31 32 34 41 42 43...     
asked by 22.04.2014 / 21:02
1
answer

How to filter separated dates by day, month and year in MySQL

Hello, I have a table "Meetings" in MySQL with the following structure:    id: Int (11), subject: String (40), day: String (2), month: String (2),   year: String (4), active: String (2) Save in the field day the day of the meeting, mes th...
asked by 23.03.2016 / 04:22