Questions tagged as 'sql'

1
answer

variables in mysql: declare, set, how to get an element from a table

Speaking of variables that can be declared within begin , I have seen that it has Declare and set only I do not know when to use them. I saw that it has set @x , set x , set x = x+1 , set x := x+1 ; they all confuse...
asked by 08.10.2015 / 18:52
3
answers

SQL query in PHP and date format

I have a function in PHP that interacts with my SQL Server. It looks like this: public function buscaRelatorioHospedagem($nome,$de,$ate){ // TODO Essa função pode ser aproveitada pra aba nova $de--; $de++; $ate--; $ate++;...
asked by 25.05.2015 / 21:09
2
answers

Error # 1062 - Duplicate entry '1' for key 'PRIMARY'

I was trying to put one of my tables as primary key . As soon as I try, the message appears:    # 1062 - Duplicate entry for key 'PRIMARY' The data is populated and looks something like this: I tried to put Sub_Id as t...
asked by 27.04.2015 / 16:01
1
answer

In PostgreSQL, which field to use for percentage?

In the table I am creating, I will have a column that will indicate the discount percentage, for example, "for a certain agreement I will have a 20% discount, for another agreement I will have a 50% discount", and I will need to use it in calcul...
asked by 27.02.2015 / 15:36
1
answer

Add Field Time MySql

Dear, I have a table with a TIME-type column, which stores the time worked on the day, and I'm trying to add these times to the end of a month, but with no success. I used the following query: Query 1: SELECT TIME_FORMAT((SELECT sum(TOTA...
asked by 03.03.2015 / 11:17
1
answer

How to model product categories?

I'm about to start developing an e-commerce, but I'm caught up in the issue of modeling, especially in product categories and subcategories. For example. A category can have several sub-categories. Each sub-category may also have sub-sub-categor...
asked by 18.09.2014 / 18:53
1
answer

How to set charset UTF8?

I have a database that was created using Firebird 1.0, at that time there was no available UTF8 charset, only from version 2.0 it was possible, so we left charset none. Questions: 1 ° How can I define UTF8 charset? remembering that the cha...
asked by 29.01.2016 / 16:05
1
answer

Select last JOIN record

I have a table tb_processos and another tb_detalhes (it keeps details of a certain process), I would like to get all the process data and only the last detail of the process. The way I'm doing I search for all records of tb_d...
asked by 16.03.2016 / 13:21
2
answers

Doubt while sql

I need to get all 5 values before ~3L of XXX: ~1BLB~2B1C~3L~1TPL~2B39~3L~1RAD~2C1D~3L And so on. I've been able to get it to get the first value before 3L with this select: db2 "select SUBSTR(FH01XXX.pnrstring,(POSSTR(FH01XXX....
asked by 05.01.2015 / 14:44
1
answer

PostgreSQL - Partial Foreign Key of Composite Primary Key

Talk to people, I need to create a structure template in which all my tables have a primary key consisting of id and version, so I can have multiple versions for each id. Problem: CREATE TABLE table1 { id BIGSERIAL,...
asked by 30.08.2018 / 15:04