Questions tagged as 'mysql'

1
answer

How to optimize this query in MySQL that is very slow?

I'm doing a simple query in LMS Moodle to get the amount of access from all users. SELECT count(userid) as total, action, userid FROM mdl_logstore_standard_log log WHERE action = 'loggedin' GROUP BY userid The table...
asked by 11.09.2017 / 16:39
2
answers

How to return a mysql query as a link?

I'm developing an application, and I'd like it when a search form search was performed, returning a value as a link to a particular page associated with the searched name, can someone tell me how to do this? Here's the part of the code that b...
asked by 14.08.2017 / 08:55
1
answer

How to return the 'Parent ID (Principal)' in this MySQL query?

I'm trying to return the parent ID at the highest level in a query, here's the information: ID NOME PARENT_ID 1 Project (null) 2 Sub 1 3 Sub-Sub 2 4 Sub-Sub-Sub 3 I need this: ID NOME PARENT_I...
asked by 05.12.2014 / 17:22
1
answer

Concatenate what is the same and separate what is different with MYSQL / PHP

Well, I think it might be a bit confusing maybe, but I need to do the following: In an example table I'm inserting multiple names in the name column, in which many of these names are the same, I'd like to join all the equal names in one query, a...
asked by 10.11.2017 / 14:10
1
answer

Return lower value of a SUM?

I have a SELECT with SUM and would like to understand how do I return the lowest sum value of all values per provider. SELECT distinct fornecedor, cliente, SUM(valor*qtd) AS TOTAL FROM orcamentos WHERE idOrcamento ='$orcamento'...
asked by 06.07.2017 / 15:27
2
answers

Grouping data from a table

I have the following sql statement: Select Notas.NotaID, Materias.MateriaNome, Alunos.AlunoNome, Alunos.AlunoID, max(case when NotaBimestre = 1 then Nota else null end) as 1bim, max(case when NotaBimestre = 2 then Nota else null end...
asked by 19.06.2017 / 16:47
2
answers

INNER JOIN in the same table

SELECT Agendamento.E3TimeStamp AS Data,Agendamento.Lote, Produtos_values.name as NomeProduto, Produtos_ValueData.TemplateID AS mp_produto FROM produtos_values inner join produtos_valuedata on produtos_values.id = produtos_valuedata.valueid,ag...
asked by 12.07.2017 / 16:36
1
answer

Error: EntityTypeT has no key defined. Define the key for this EntityType

When I run my application, the following error is generated:    One or more validation errors were detected during model generation:   BolaoSCA.DataAccess.Context.InstallMap:: EntityType 'InvalidMap' has no key defined. Set the key for this E...
asked by 12.07.2017 / 03:44
1
answer

1060 - Duplicate column name 'NULL' in a MySQL query

I'm trying to run this query, and it always gives me the following error: 1060 - Duplicate column name 'NULL' INSERT INTO ce_coins_issued (idc, idu, year, ltr, issuing, status) SELECT * FROM (SELECT 2,1,2002,NULL,NULL,'wallet') AS tmp WHERE...
asked by 30.07.2017 / 14:55
1
answer

Query in column type date with filter of the current week

I've been looking for a mysql command to do that. The purpose of this is that I have to display a schedule of items for the current week. From Sunday to Saturday. Is there a query that does this filter? Well the column is of type date, Y-m-d.  ...
asked by 03.08.2017 / 05:13