Questions tagged as 'query'

1
answer

SQL query help

I have 3 tables: Company: id integer nome string category: id integer idEmpresa integer nome string tag: id integer idEmpresa integer nome string I'm querying as follows: SELECT distinct(e.nome), e.id, e.logo FROM empresas e,...
asked by 01.04.2018 / 18:00
3
answers

Search for a higher date by a specific ID

I have a problem with a SQL where I need to search for the largest date of a specified ID , where it has several records of this ID : Data:    ID - date - name       2 - 10/10/2004 - cesar 5 - 10/10/2008 - joana 4 - 1...
asked by 01.02.2018 / 13:02
2
answers

How to join these 2 SELECTs in the same query

Good morning, I'm redoing the question because the last one I deleted because it was a bit confusing. I have these two select and would like to join them to return the result for a comparison chart. This SELECT query and returns me the nu...
asked by 01.02.2018 / 15:23
1
answer

Split between values - Query SQL Server 2012

Galera, in the query below, is as follows. Ano Mes Horas total_horas 2018 1 107 766 H 2018 1 225 766 H So, I want you to bring in another column the division of the column "Hours" by the column "total_horas", bringing this...
asked by 17.01.2018 / 14:15
1
answer

Check changes to the database correctly

I need to check changes in my database and I created a script that sends requests every millisecond by calling a function that returns the number of rows in that database, but I realized that it is a very wrong way to do this because it leaves m...
asked by 09.01.2018 / 21:01
1
answer

I can not retrieve the id value through the POST method

I have the following functions: Archive registra_conta.php: if(isset($_POST['acao'])){ if($_POST['acao'] == "inserir"){ inserirConta(); } if($_POST['acao'] == "alterar"){ alterarConta(); function selectIdConta($id){ $banco = ab...
asked by 29.01.2018 / 20:24
1
answer

Do not select records that have the status = 'Off'

$query = "SELECT uf , count(*) as number FROM tab_clientes GROUP BY uf "; It is working fine however I have in the database a status field that classifies the person as Off (need to remain registered for other reports). I would like the rec...
asked by 19.01.2018 / 15:26
1
answer

SQLite error: foreign key mismatch (fk incompativeis) when trying to do an INSERT

I'm trying to create a Associative Entity (N: N) in SQLite like this:    [Pet --- < VaccinePet> Vaccine] And, here is my Associative Entity code CREATE TABLE VACINAPET ( vp_data TEXT NOT NULL, vp_is_aplicada INTEGE...
asked by 18.01.2018 / 00:48
1
answer

Define variable as null in a Query in php

I have the following QUERY on my system: $Query = "SELECT * FROM Monit WHERE ($Modulo IS NULL OR Modulo = '$Modulo') AND ($Usuario IS NULL OR Usuario = '$Usuario') AND ($Data IS NULL OR Data_reg = '$Data') ORDER BY Data_monit...
asked by 20.02.2018 / 15:34
1
answer

Doubt with select case

I have the following query: select f.no_equipe, i.no_cbo, count(b.tp_atend) from tb_equipe F, tb_cds_prof G, tb_cbo I, tb_cds_ficha_atend_individual D, tb_cds_atend_individual B where F.nu_ine = G.nu_ine and G.nu_cbo_2002 = I.co_cbo_2002...
asked by 18.12.2017 / 14:19