Questions tagged as 'sql'

1
answer

When to use the OVER clause?

The Documentation says:    Determines the partitioning and sorting of the rowset before   of the associated window function. An example I created just to demonstrate this: select ROW_NUMBER() OVER(PARTITION BY cor order by carro ) fro...
asked by 10.11.2017 / 20:11
1
answer

How to Migrate PosgreSQL Script to Mysql Script?

I have this database in Postgresql Script, how to convert to Msyql in order to create this database in this database? -- -- PostgreSQL database dump -- -- Started on 2010-07-03 09:40:14 SET statement_timeout = 0; SET client_encoding = 'UTF8'...
asked by 06.10.2017 / 18:30
1
answer

How do I get the results of two tables by querying one with PDO?

I have the table establishment, table unit, and table professional. In the unit table, I have idestablishment. On the professional table, I have the idunity. I need to find all the data of the professionals by the id of the establishment. Anothe...
asked by 09.08.2017 / 22:11
1
answer

Separate column in multiple lines (split)

I have a cidade_bairro table with several cities and neighborhoods. I want to transfer this data to a new table, but on several lines instead of being in one. EX: Cidade Bairros<br> SP | Consolação-Morumbi-Saude In the n...
asked by 13.09.2017 / 20:34
3
answers

Return Id's That Are Not in the Database - MYSQL

Problem In a table X and I have N records, however these records are not sequential (throughout insert ), Id will always be greater than previous, but not necessarily the number following the previous one.) I need to know what id's...
asked by 10.08.2017 / 16:23
1
answer

ExecuteSqlCommand - Update byte - Error

Follow the code below: var bytes = ConvertTo.Bytes(file); int num = ctx.Database.ExecuteSqlCommand( $"UPDATE dbo.Table" + $"SET Video = '{bytes}' " + $"WHERE id = {Id} "); Follow the code to convert: public static byte[] Byte...
asked by 09.11.2017 / 15:26
2
answers

Doubt with SELECT in MYSQL database

I need an sql that, in the table below, always brings the last insert for each user. I tried with distinct but it did not work. So in the case below sql would bring the results of line 2 and 5. Detail that there are more columns (city, country,...
asked by 17.07.2017 / 23:00
1
answer

Duplicate record in database with new id

I have a table in the database called user, with n fields, how can I duplicate a certain record only with a new id? insert into usuarios * select * from usuarios where id = x? obs: this id is a non-null primary key     
asked by 18.07.2017 / 03:02
1
answer

How to remove the first character of a string in a Query

In PostgreSQL 9.2 I have a column with the following information: A101 B12 C3 I need a command to select and another one to update that column by removing the first character by doing so: 101 12 3 I tried to solve with the substring...
asked by 01.09.2017 / 22:32
1
answer

Doubts about JPQL

I honestly have some difficulty with BD, and I need a JPQL that returns only one record. I have an Entity Price and an Entity Product. I need to bring the last price registered by the user. I put a date and ID, I imagine it could be the last ID...
asked by 19.08.2017 / 01:03