Questions tagged as 'sql'

0
answers

Error creating Trigger

create or alter trigger CAD_TERCEIROS_BI0_CPF_CNPJ for CAD_TERCEIROS -- cria a Trigger active before insert position 0 -- Posição que a trigger vai ser executada as begin if (exists(select -- faz a verificação se já existe 1...
asked by 11.04.2018 / 19:59
0
answers

SQLSTATE error [42S22]: Column not found: 1054 Unknown column '' laravel project, table with two foreign keys

Function in the controller for voting projects has two foreign keys, user_id and projeto_idProjeto , follows function: public function votar($id){ $usuario = Auth::user()->id; $votoss = Votos::where('projeto...
asked by 10.04.2018 / 16:44
2
answers

Delete duplicate records in MYSQL

I'm using a command that runs every second on node.js. It has the function of excluding any duplicate records for a given item, which is specified as in the example by AND t1.auction_id = 1335 . DELETE FROM bid_account t1 WHERE t1.id <...
asked by 14.04.2018 / 21:14
0
answers

Query by part in SQL clause IN

I have to query more than 400 thousand records in the IN clause. It turns out that I can not do everything at once because I can crash the system of my company. So I have to run at a specific time and every 5,000 at a time. But I do n...
asked by 11.04.2018 / 15:20
0
answers

Add / View Friend Database

I have a users table and a friends table, every friend is also a user, I would like to know how to insert items (add a friend) and how to check (list friends)? CREATE TABLE IF NOT EXISTS usuarios( id INT NOT NULL AUTO_INCR...
asked by 08.04.2018 / 15:02
2
answers

Trigger with column check

I need to make a trigger in mysql, but I need it to run only when there is an update in the auctions that change the status to 3 or 4. It is of type AFTER UPDATE BEGIN IF (NEW.status IN ('3','4')) THEN QUERY_AQUI END IF; END     
asked by 05.04.2018 / 20:28
0
answers

Help in procedures triggers and basic SQL functions

Personal the question is this: Develop 4 screens of cadastros , Usuários , Cidades , UF and Produtos . For each screen you should have the procedures of insert , updade and delete . You shoul...
asked by 18.06.2018 / 04:14
1
answer

Sub query in a single SQL field

I need to create a code where I do the UPDATE of a field always adding a value to what already exists. Example table assuming it is already population CAMPOS: ID | EMAIL | QUEMCURTIU 1 |[email protected]| 3, 46, 81, // below the user ID...
asked by 01.04.2018 / 06:05
1
answer

Delete table record with foreign key

Where is the Error? DELETE FROM postagens WHERE id='$p_id' AND u_id='$u_id' SET FOREIGN_KEY_CHECKS = 0; Clarifications: p_id = post id (primary key) u_id = user id (foreign key)     
asked by 01.04.2018 / 20:09
0
answers

Problem with cyclic relationship

I have a question: I have a user who submits documents that are read by other users. Is there a problem in this cycle?     
asked by 02.04.2018 / 14:02