Questions tagged as 'sql'

2
answers

Concatenate fields in a more performative way

I am concatenating the description lines of a record so that instead of having N records for a description it has only one. I can make it happen, but I wanted a more performative way, because I'll do it with a table with some 900,000 records....
asked by 12.03.2016 / 01:03
3
answers

GROUP BY last record

I'm doing a query in the database, follow my table below id | protocolo | status | alteracao | datahora 1 2 1 teste 2014-11-10 15:23:44 2 2 3 teste 2014-11-10 14:23:44 3 2 4...
asked by 10.11.2014 / 18:47
1
answer

How to select categories and count number of products of each category?

I'm trying to select the categories of the database and count in the same query the number of products registered in that category. So far so good, the problem is that I can not return the category when there is no product registered, for exampl...
asked by 05.05.2014 / 22:09
1
answer

When to use a unique constraints vs unique indices in Oracle?

Is there some kind of good practice and / or recommendation when creating unique indexes vs. constraints in Oracle? When should I use one and when should I use the other? Is there a situation where I should use both? ALTER TABLE t ADD...
asked by 17.12.2013 / 11:44
1
answer

How to return the last value of an sql string?

I need to use the last character of a string G. How do I get it with sql server? SET @VALOR = '0000050529-G' I want to get the letter G     
asked by 13.12.2018 / 14:04
1
answer

Why (a x b) produces a result other than ((a x) and (x b))?

List all fields of all products whose cost plus 30% is greater than 8 and less than 10. That was my answer: SELECT * FROM 'produtos' WHERE (8 < (pcusto*1.3) < 10); This is the template: SELECT * FROM 'produtos' WHERE 8 < (pcus...
asked by 14.09.2018 / 18:00
7
answers

How to use multiple SQL statements (in the delete case in ORACLE) on a single line in C #?

I made a command because of foreign keys, just to plug hole, but it is not working because of an invalid character error, I believe it is ";" . I know I'm doing this the wrong way, so I accept suggestions for a more appropriate code. At...
asked by 05.02.2014 / 14:11
2
answers

MariaDB ERROR: ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes

When I run this code in MariaDB, it gives me this error when trying to create the toy table:    ERROR 1709 (HY000): Index column size too large. The maximum column   size is 767 bytes. I do not know how to fix, MariaDB has already install...
asked by 30.12.2016 / 14:14
3
answers

"Smart" columns in MySQL

Is there a way I can assign something to a column in MySQL so that when I perform the query I select them? SELECT filtro_1,filtro_2,filtro_3 FROM filtros But if the table is changed (like adding a new filter, now the filtro_4...
asked by 23.05.2015 / 06:46
1
answer

What size of a large considerable query?

What size of a large query ? I need to make a function to send query to the server but I can not exceed the limit to not crash the server: public function sqlExecute($sql_code) { if ($sql_code != "" && strlen($sql_code) &...
asked by 05.04.2015 / 01:37