Questions tagged as 'sql'

1
answer

Query to count how many fields equal to 0 a record has

I need to return as many fields as 0 each record has and rank the one with the zeros down. Example: id | col2 | col3 | col4 1 | 1 | 0 | 0 2 | 0 | 0 | 0 3 | 0 | 1 | 4 4 | 0 | 3 | 5 5 | 3 | 2 | 40...
asked by 17.11.2017 / 16:54
1
answer

Update with select CTE Error

I'm having a hard time performing an update with select CTE. I want to refresh the taridinclusao field. Below is the query and just below is the update that I tried to perform, however, the following error occurs: "The 'historical' derived table...
asked by 27.09.2017 / 18:54
2
answers

Accented words are not sent to the database - PHP

I made a form that sends data from a php page to a database, and only the unencrypted data is being sent; if I put an accent, nothing in that field arrives in the database, not even something blank. Thanks in advance for any help Code sni...
asked by 07.11.2017 / 19:38
1
answer

How to make foreign key one-to-many in mysql?

I have a student table and a table courses, my table courses have the course eg administration, how do I relate several student to this table using Foreign key?     
asked by 04.11.2017 / 02:12
1
answer

Select database data within another while?

I have a calendar made by me, not very good, but done by me, in which you have a while that creates squares, that is, the days, of the current month. So far so good, but now I would like it if one day had an event, it would change the color of t...
asked by 02.11.2017 / 18:41
1
answer

How can I not register a foreign key?

I have a database of an electronic ballot box with the following tables: Voter ( Pk titulodeeleior, name) Feedback ( Fk titulodeeleitor, vote) To my knowledge, the VotosComputados table should not insert a FK any, but one...
asked by 22.10.2017 / 03:21
1
answer

Find difference between two tables

I wanted to set up an sql statement that would return differences between two tables. For example, I have the arquivos table and the conferencias table where you have equal fields called titulo and valor , if in any...
asked by 23.09.2017 / 14:48
2
answers

WCF does not connect to SQLServer when published in IIS

I'm using WCF + SQLServer, when I run it through Visual Studio it works perfectly, when I publish and update in IIS an error occurs:    "A network-related or instance-specific error occurred while   establishing a connection to SQL Server. Th...
asked by 26.09.2017 / 20:26
1
answer

Problem with subquery

Good evening, I need to bring the complete subquery result: (select (valor * 0.05) from tbl_exames) as 'Valor dos Exames', In a delimiter: delimiter // create procedure comissao(idmedico int) begin select nome_medico as 'Médico',...
asked by 26.09.2017 / 04:41
1
answer

How to do column operations where nicknames are given?

I have the following hypothetical query to the bank: SELECT dinheiro_na_carteira, (SELECT sum(despesas_pagas_carteira) FROM DESPESAS WHERE id = X ) as despesas FROM RECEITAS WHERE dinheiro_na_carteira - despesas > 0 When trying to do t...
asked by 30.11.2017 / 12:10