Questions tagged as 'sql'

3
answers

Select the dates below a certain year

How can I create select to show only the employees of a company that have been admitted to it before a given year? The type yearAdmission is date ie: dd-mm-AA     
asked by 07.02.2018 / 20:31
2
answers

Trigger to retrieve Last Record Inserted into table in PL-SQL

I have a trigger that after inserting a new user in the table tFuncionario I have to fill another table tPlanoSaude with the data of the official. Employee table HealthPlantable TriggersCodeCREATEORREPLACETRIGGERINSERTFUNCIONARIOBEFOREINS...
asked by 08.02.2018 / 21:02
2
answers

Foreign key for different tables (MySql)

At the time of executing the error query stating that it is not possible to create the foreign keys, I looked in the documentation and did not understand whether this code is possible or not. create table autor( cod_autor integer, nome...
asked by 21.08.2018 / 05:24
1
answer

What is the lowest direct query weight or using views for a double relationship?

Given the following hypothetical schema: create table cidade( cidade_id integer primary key not null, nome varchar(40) ); create table envios( id integer primary key not null, cidade_origem_id integer, cidade_destino_id intege...
asked by 07.07.2018 / 16:38
1
answer

Change column value in Firebird

I have a table with approximately 7 thousand records, I need to create a new column in this table but I would like all the old records to have the value 'S', when I try to create the column the fields get null value, passing as default ' S'. How...
asked by 07.12.2017 / 12:19
2
answers

Display ID in form before registering php and mysql

I'm doing a sign-up screen, but I wanted the system to already display the ID (id_entity) that will be registered. When saving, it will ask if I want to register documents, then if I click on yes, it goes to a new doc registration form that when...
asked by 24.12.2017 / 19:26
2
answers

Generate an array inside XML in sql server

I have the following problem: I'm running a Procedure in Sql Sever that generates an XML to me via the XML PATH command, however, one of the fields is an array, what I got was this: This select is inside the PROC which is what matters to...
asked by 03.01.2018 / 15:13
3
answers

Display more than one information in the same table with PHP and MYSQL

I would like to display in the table the information of the registered student and also of the courses that he is enrolled in. Final result you'd like displayed: Nome Aluno | Telefone Aluno | Cursos ---------------------------------------...
asked by 06.01.2018 / 18:33
1
answer

Column that receives a result if the condition is true

SELECT DISTINCT P.CD_PACIENTE , P.NM_PACIENTE , DECODE (P.TP_SEXO, 'M', 'MASCULINO', 'F', 'FEMININO', 'I', 'INDEFINIDO') SEXO , TRUNC(P.DT_NASCIMENTO) DT_NASCIMENTO , (SELECT FN_IDADE (P.DT_NASCIMENTO,...
asked by 02.05.2018 / 22:00
1
answer

order by specific text [closed]

How do I order by by text criteria? I have a column with some classifications and I wanted it to come in the order I determine. Example: 'carro1' 'carro3' 'carro5' 'carro10' 'carro2'     
asked by 12.06.2018 / 21:08