Questions tagged as 'sql'

2
answers

Return which of the query items are not in the table?

Is there any way to return which query items are not in a table? Let's say I have a query like this: SELECT id FROM tabela WHERE id IN (1,23,45,68,91,126,345,418,509,610); This will bring me a table with the query records that are prese...
asked by 01.10.2014 / 20:42
2
answers

Query N records by Item

I have a history table in DB2 and I would like to do a grouping by PLACA but despite this I would have to return the last 5 records of each PLACA . Ex: |ID |PLACA | DATA | VALOR | |12 |ABC | 2014-08-28 | 4.50 |...
asked by 28.08.2014 / 20:17
1
answer

Validation of the strings size

I was creating a function to validate large text fields (description, observation, ...), which in SQL will be saved as TEXT , so basically I did this: function($valor, $min = 0, $max = 65000) { if (strlen($valor) >= $min || strlen...
asked by 28.09.2018 / 15:37
1
answer

How to do PIVOT from a column, concatenating strings in SQLServer

Hello, I am doing a query in a database to identify all the columns that are primary key 's of the tables of a database and also to identify if they are identity . For this I use the query below: SELECT OBJECT_NAME(C.OBJECT_...
asked by 21.08.2018 / 16:21
1
answer

Random Records with Criteria

I would like some SQL command for an MS-Access database where I have 500 records and only 20 records to return random being these (10 in 10 MEN) and sorted alphabetically by name. The structure of the tbLista table is very s...
asked by 20.08.2018 / 17:31
1
answer

Product Structure Select

Good morning! Is there a way to create a query that brings the "product" and all "Components and Subcomponents" of the structure of this product? Let me try to explain better Structure Image LinktoImage: link Text format...
asked by 08.08.2018 / 13:48
1
answer

Remove images that are not present in the database

I started working on a site already made by an old programmer that has a page for insertion and removal of images. However, when it removes, it only takes the database leaving the image there, ie, it takes up space. It's been 2 years since the p...
asked by 29.06.2018 / 12:43
2
answers

Place If no Where

I have the following Where WHERE 1 = 1 AND (0 = 0 OR 1 = 1) inicio do if AND (2 = 2 OR 3 = 3) fim do if How would I do if? The idea is for one value per parameter to come in, and if that value satisfies if...
asked by 13.12.2017 / 12:39
1
answer

(SQL) Each property has several images and a cover image

Suppose I have a Property table where a property can have multiple images. I have, therefore, another table, Images, with the url. I also have an intermediate table that makes the N: N relationship between Real Estate and Images. If I w...
asked by 15.12.2017 / 15:27
2
answers

Error with insert in SQL Server: The conversion of a varchar data type to a datetime resulted in an out-of-range value

Next I have to do a search and implement a query in the database using Merge and I have to do this using one of the scripts used in class. The problem is that when I run the script it gives the following error in insert and the...
asked by 20.11.2017 / 17:31