Questions tagged as 'sql'

2
answers

Execute query sql

$sql = "exec atualizar_feira '".$nome."', '".$endereco."', '".$cep."', '".$escolaridade."', '".$instituicao."', '".$telefone."', '".$email."', '".$aluno_cairu."', '".$curso."', '".$curso2."', '".$palestra."', '".$data."' "; $result = mssql_query...
asked by 31.01.2017 / 22:30
2
answers

How to query data from a table using INNER JOIN in a subquery in PHP

I have the following SELECT to select data from a table ( chat ) on a chat system: SELECT * FROM (SELECT * FROM chat WHERE id_chat = '$chat_id' ORDER BY id DESC LIMIT 10) S WHERE id_chat = '$chat_id' ORDER BY id ASC LIMIT 10 Th...
asked by 12.01.2016 / 00:49
1
answer

Friends system in PHP and SQL

I have a problem and still have not found the solution. I have 2 tables, one for users and one for friends. In the user table I save id and username In the friends table I have the field user_1_id and user_2_id ,...
asked by 10.01.2016 / 04:08
1
answer

What is the best way to do these Triggers?

I wonder if there is a better way to write these triggers. I thank you --gatilho para gravar os dados do usuário CREATE TRIGGER TGR_TB_USUARIO_INSERT ON TB_USUARIO FOR INSERT AS BEGIN DECLARE @IDUSUARIO INT SELECT @IDUSUARIO = IDUSUAR...
asked by 16.06.2015 / 03:13
4
answers

Error in SQL like

I'm trying to do a select where I want all the data from a person who has the same ip and date equals today's date. The reason is that I need to restrict how many times a person sends contact to my system. below my code. $ip = $_SER...
asked by 23.06.2015 / 19:55
2
answers

How to select the foreign key id in the main table? [duplicate]

public List Select() { List ListaCaminhao = new List(); SqlConnection conexao = new SqlConnection(strCon); string sql = "Select * from Caminhao;"; SqlCommand cmd = new SqlCommand(sql, conexao); conexao.Open()...
asked by 31.03.2016 / 14:31
1
answer

Structure the paths to the images and videos of my product in the bank?

How can I structure the paths to my product images and videos in the database? Below is the SQL for creating the product table: CREATE TABLE products ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL, quantity INT NOT NU...
asked by 14.07.2015 / 18:50
3
answers

Get value of a variable in Sql Server

I have this Sql block: SET NOCOUNT ON; Declare @QueryString as NVarchar(4000), @Datazero as varchar(20), @Datamn as varchar(20), @CdUsuario as integer, @SitProcesso as int ,@DsUsuarioRede varchar(20) ,@Processo as int...
asked by 10.03.2015 / 15:21
3
answers

Create a trigger that is executed whenever a product is deleted

How to create a trigger that is executed whenever a product is deleted by performing the deletion action on all batches related to the deleted product. Here's my SQL code: create database provafinal; use provafinal; create table prod...
asked by 26.11.2014 / 17:36
1
answer

Select Subqueries

My bank looks like this: cd_cliente | nr_ddd | nr_telefone 30 | 11 | 25622791 30 | 11 | 25622791 My select is like this: "SELECT * FROM tb_telefones WHERE nr_ddd="+ddd+" AND nr_telefone="+telefone+"";...
asked by 25.11.2014 / 14:12