Questions tagged as 'sql-select'

1
answer

I can not display the value of SQL

I'm trying to start a MySQL database connection and it works, but when I request that PHP display what it has there nothing appears. It's as if the connection to the BD had failed. <?php // definições de host, database, usuário e senha $s...
asked by 25.12.2014 / 21:44
2
answers

How to calculate the difference between values that are in the same column?

I wonder if there is any way to calculate the difference between values that are in the same column. For example: I have a table with 2 fields: date and balance. I need to add a new field containing the balance difference from one date to anothe...
asked by 09.12.2014 / 18:46
3
answers

Query on sql query

I have a question. I think it's not very complex, but I could not solve it. For example, I have this query: select * from Paciente where ClinicaID = 3 Your result would be these 3 records: NomePaciente HoraAtendimento Ativo Clinica...
asked by 28.11.2017 / 23:55
1
answer

How to group COUNTs for different queries in one?

I need to do a SQL query to count indications, I have the following querys : SELECT 'FACEBOOK', COUNT(id) FROM 'clientes' where indicacao like '%face%' SELECT 'Instagram', COUNT(id) FROM 'clientes' where indicacao like '%insta%' SELECT 'go...
asked by 24.11.2017 / 15:41
1
answer

How to list a sample of all tables in a MySQL database?

I need to sample all the tables in a MySQL database, for example through SELECT * ... LIMIT 10 . I already have the code that returns all the tables in the current database: select table_name from information_schema.tables where table...
asked by 26.09.2014 / 19:08
1
answer

Sending data from one table to another with the deleted command

I'm creating this trigger in SQL Server , but I'm not getting the id to send the data to another table and delete this table. CREATE TRIGGER MoveComprador ON comprador INSTEAD OF DELETE AS BEGIN SELECT * INTO bk_comprador FROM...
asked by 19.06.2015 / 06:31
1
answer

Select per group

Good morning guys, I'd like to know how to do the following SELECT in mysql: Having the following table, I need to select the last 3 purchase of each Name: From now on, thanks     
asked by 03.04.2017 / 14:45
1
answer

Tracking and posting system (social network type)

I am developing a new project and I am creating a system of profile followers, in which the purpose is to show only the publications of whom I follow. Like for example the one of a social network. I follow the person, so I get the person's publ...
asked by 13.12.2014 / 19:59
1
answer

What is the weight of a subquery for the query?

During the development of some queries in the database, I come across the situation of the need to perform a new query, but another solution in some cases may be the subquery. So what is the best solution to perform a second query or use subq...
asked by 08.05.2014 / 15:37
3
answers

Error performing a database query

I'm using Zend and I have the following function: public function getChamado($id) { try { $cols = array( 'id', 'titulo', 'descricao', 'fk_status', 'fk_local', 'fk_tipo', 'created', 'modified', 'finished', 'fk_usuario',...
asked by 31.01.2014 / 00:09