Questions tagged as 'sql'

2
answers

MySQL error "expects parameter 1 to be resource, boolean given in"

$query = "Select * from servico where ID_SERVICO = $id"; $result = mysql_query($query); if($row = mysql_fetch_array($result)) { $nome = $row['NOME']; if($nome == 'Marketing') { include ("servicos/marketing.php"); }...
asked by 07.08.2014 / 19:13
1
answer

Remove data from one table from the average of notes in another table?

Tabela - lista id | nota 1 | 10 2 | 8 3 | 7 1 | 8 3 | 9 I want to average the grades of those who have the same ID, and for this I have created the following query: SELECT AVG(nota) FROM lista GROUP BY id With this query I want...
asked by 13.05.2017 / 23:29
1
answer

Safe update error using stored procedure in MYSQL

I'm having trouble updating my stock table using a stored procedure in MYSQL. Here is the code: CREATE DEFINER='root'@'localhost' PROCEDURE 'atualiza_estoque'(id_produto int) BEGIN update estoque e inner join reposicao r on r.produto = e.prod...
asked by 13.05.2017 / 00:13
1
answer

Error 1452 Mysql

I'm starting mysql, so do not look at bad tables. Anyway I have the following tables: create table Alunos ( MAT int, nome varchar (45), endereco varchar (45), cidade varchar (45), constraint primary key (MAT) ); create table Disciplinas (...
asked by 13.05.2017 / 01:32
1
answer

Condition and loop within a function

I am creating a function to output inventory, where v_saldo_item_peps is a function that returns a table, with the items that have balance, in their respective entries. I need to check if v_saldo_item_peps returned some result a...
asked by 19.06.2017 / 16:30
0
answers

Add column to SQL considering some conditions to be valid

I'm trying to put together two pieces of information and I'm not getting it. I set up this SQL to bring me only the products that were purchased that had a discount through a contract. But this discount was registered for the product categori...
asked by 19.06.2017 / 22:59
1
answer

Bring the word HISTORICAL when the Line Date is shorter than the previous dates,

I have a query where I should record the rows with error with the word History, the rows that bring the date LESS than any of the dates of the previous rows should display the word HISTORICAL, Can you help? the column in question is TYPE, T...
asked by 24.05.2017 / 03:31
4
answers

Excel transpose row to column and preserve columns and replicate them online

Good morning! Next, I have a csv as follows A; B; C; D; 1; 2; 3; 4; 5 E; F; G; H; 6; 7; 8; 9; 10 The columns of letters have a regular structure, and those of a number not but it could explode them and put them in columns but it will...
asked by 10.05.2017 / 16:59
0
answers

Code Igniter - How to call a procedure that is in another database?

I have a SQL Server where we have several databases and their schemas. So that's fine, but I need to access a stored procedure that is in the X bank. I have tried this: $ this-> db-> query ("cadunico.dbo.CadUnico_Educacao_Consultar"); but whe...
asked by 10.05.2017 / 21:18
2
answers

Relate 3 tables in one row - MYSQL

I want to make a linked table information from 3 tables. This table will be sorted by date (day / month / year Hours: Minutes) and visually speaking would look like this Image of the table For better understanding I will post the structu...
asked by 12.05.2017 / 04:12