Questions tagged as 'query'

2
answers

How to count how many rows a query to the database returned (Cake PHP)?

$this->Post->Comment->find ('all', array('conditions' => array('Comment.post_id' => $id))); I make this query, how do I know if it returned 5, 7, 10 ... comments before displaying them in the view?     
asked by 23.12.2014 / 00:09
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 2 tables same time

Good night, folks, I need help in a query 2 tables if there is an id in the second price appears if price does not appear in the first table .. example table1 table2 ----------------------------------------------- - id | description...
asked by 26.10.2017 / 04:39
1
answer

Query query - SQL Server 2012

Good afternoon! Well, I do not know if that's possible, but I wanted to know how I can get a one line record to stay on another line. I will illustrate. In the query below is coming out like this. Projeto Operador...
asked by 04.08.2017 / 19:18
1
answer

Adding cases to a query

I need to create a query that adds 2 cases , but I can not do it the way I did. If the D3_UM = 'PC' field, it should add the D3_QTSEGUM field. If the field D3_UM <> 'PC' , it should add the field D3_QUANT ....
asked by 27.03.2017 / 15:02
2
answers

How to add up the amount of records where the penultimate record enters Where?

I need a query , in MYSQL , where I check the penultimate record and that this record is equal to a certain value and counts the number of records found . Ex: penultimate record is from John. I need to count the number of times John appears...
asked by 23.08.2017 / 14:54
2
answers

Problem with query mysql, what would be the best way to solve

Hello, I'm trying to make an appointment for an ordering system for a restaurant. My tables are arranged as follows: I need to bring all tables (regardless of whether or not they have a request) if they have a request with status 0, such...
asked by 25.01.2017 / 14:47
1
answer

SUBCONSULTATIONS IN SQL?

Using the DB below, how would you return the name of the person you rented on the date '2016/11/17'. Name is in the person table and the date in the loan table. CREATE DATABASE escola; USE escola; CREATE TABLE IF NOT EXISTS acervo ( id in...
asked by 18.11.2016 / 13:24
1
answer

mysql Rank grouped function for a COUNT

I have 3 tables in MYSQL represented here as an example: IneedaquerythatreturnsaRANKofcontractsexecutedgroupedbycommercialinagivenperiodoftime,forexample:AquerythatreturnstheRANKofthecommercialsbetween2016-01-01and2016-01-03,shouldlookliketh...
asked by 04.12.2016 / 17:50
1
answer

Query to return only the records of the last 24h (Codeigniter)

Hello I need to do a query that returns me the values of only the last 24h I have the following query: $date = date("Y-m-d H:i:s"); $this->db->select('*'); $this->db->from('inscricoes');...
asked by 03.08.2016 / 13:24