Questions tagged as 'sql'

1
answer

Sql - Merge select - Create row if none exist

I want to join two SELECT , but I'm unsuccessful. It has the following tables: CREATE TABLE tb_producao ( cd_producao SERIAL, cd_setor integer, nr_quantidade numeric(12,2), ds_producao character varying(255) ); CREATE TABLE t...
asked by 14.10.2015 / 16:31
1
answer

How to "truncate" table to restart from lowest auto increment value

The tabela_A has a id field with auto increment. I need to clear the table with something similar to the command truncate only cleaning only the registry from id = x . For example: id col1 1 A 3 B 4 C 5 D 30 E...
asked by 20.04.2016 / 23:25
1
answer

How to execute trigger sqlserver

How can I perform a trigger on unit tests. I have a trigger I have a trigger as an example: ***-- Create one trigger with two inserts:*** create trigger trg_I_Table_1 ON Table_1 FOR INSERT as insert into Table_2 (Col_1, Col_2, Col_3)...
asked by 18.04.2016 / 20:12
2
answers

Comparing variables in a query

I need to create an if to check if the field coming from POST is empty or not, in case I should be null, if I do not seto the value that came in the variable. $query2 = "INSERT INTO tbl_CLIENTES_PF (COD_IDENT_CLIEN, TXT_NATUR_CLIEN, TXT_NACI...
asked by 31.07.2015 / 15:32
1
answer

add a foreing key to an existing table

I have to create a column in an existing table and at the same time create a foreing key with another table using this column that was created, and this foreing key by default must be null. The way I'm doing is IF NOT EXISTS (SELECT * FROM SY...
asked by 08.07.2015 / 21:09
1
answer

Error inserting JDBC data

I'm having the following problem, I want to insert the data from my expense table but some error occurs with my foreign key, what can it be?    expensea: Can not add or update child row: a foreign key constraint   fails ( trabalhoviagemd...
asked by 04.07.2015 / 04:09
1
answer

Help - Conflict of Collation

Sirs, good afternoon, Could you help me identify a problem? I am changing a PROC and testing it is the following error:    Can not resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the s...
asked by 10.07.2015 / 16:43
1
answer

SQL - Category & Subcategory

I have a category structure and subcategory. And you need to list all categories, and then your subcategories ... But the listing went wrong. I'm using codeigniter . Database Structure: SQLStructure:SELECTc1.*,c2.id,c2.id_categoria,c2.ca...
asked by 13.11.2015 / 01:25
2
answers

Query for MYSQL with IF to validate multiple table fields

I'm developing a Real Estate Classifieds, so I need to filter some fields if the user wants them, such as: Number of rooms, Number of parking spaces, Number of bathrooms, etc. I need Query to have IF so I can validate if the variables are fil...
asked by 30.03.2016 / 21:12
1
answer

Select with exception of values (SQL / Oracle)

I need to improve this select that already exists here to perform a query where the ICCIDs started by 8995 are not returned, but I do not have much knowledge of the database. How can I change this select? I use SQLDEVELOPER, however the clien...
asked by 08.06.2015 / 17:06