Most voted "sql" questions
Structured Query Language (SQL) is a language to query databases. Questions should include examples of table code and structure. This tag refers to the default language, not to be used for questions about the implementation of specific DBMS (such as Mysql, Postgresql, Oracle, MS SQL Server). In this case use the specific DBMS tag. Answers to questions marked with ANSI SQL should use SQL as much as possible.
Learn more…6,771 questions
Sort by count of
-
0
votes3
answers677
viewsreduce the size of an image in the database
I have a table that shows the contents of a database, one of the contents is an image, call the image as follows: <td><?php echo '<img src="data:image/jpeg;base64,'.base64_encode(…
-
0
votes1
answer150
viewsC# Combobox and SQL
I would like to know how to load values in a combobox, listing an entire column of the database, for example, I have a column called "Beer" and it has several names, I would like to list this column…
-
0
votes2
answers753
viewsUNION with 2 DATABASES, SQL
I need to integrate 2 TABLES from DBdifferent in one DGV. I found several tutorials, but none that helped me from setting up to the connection, at least not the way I work with the connections.…
-
0
votes1
answer3342
viewsGenerate database script with structure and data
Backup is not possible to do, because it depends on permission from France and etc. So, the solution we found here was to try to generate a script that copies not only the structure of the tables, I…
-
0
votes2
answers480
viewsReturn primary key after insertion into Mysql
I need to insert into my database two tables, one of the tables has a primary key and the other will use this value as a foreign key. My question is: How can I return the value of this primary key…
-
0
votes1
answer58
viewsHow to sort a list by current time and next dated records
I have the following table containing the schedule of the day of the week "Sunday" of a radio: (id,script,hora_ini,hora_end,link) I want to get the first 3 programs using as reference the current…
-
0
votes1
answer130
viewsExport DESCRIBE TABLE from Postgres to txt
Is it possible to generate a file . txt with the DESCRIBE TABLE of a table in Postgres by PHP? I need to make a file download available. txt with the description of the fields(name, type, character…
-
0
votes2
answers1212
viewsFigure out which column would be truncated (date would be truncated)
good evening! When trying to enter a record in Sqlserver through my application I am getting a truncated data message. The problem is that there are many columns that this screen fills and I have no…
-
0
votes1
answer99
viewsHierarchical database(?) - Sqlite/Android
Good afternoon, I’m starting to study Android and thought of making an app to already study together database. I want to make a "family tree", so that clicking on the person’s name (button) would…
-
0
votes1
answer3263
viewsHow to assign the query cost to a variable in Postgres
To take the cost esteemed of the query use the EXPLAIN SELECT coluna FROM tabela;, to take the cost current of the query use the EXPLAIN ANALYSE SELECT coluna FROM tabela;, my doubt is how to search…
-
0
votes3
answers5873
viewsRemove repeated lines in all aspects on Oracle
In a column REGISTER I have two lines repeated in all aspects: NOME ID EMAIL SEXO JOAO 1234 [email protected] M JOAO 1234 [email protected] M How to compare these two rows, check if all columns are…
-
0
votes0
answers50
viewsQuery of multiple Mysql data
I’m doing a chat and I have the following table in the bank: I want to list the last 5 conversations of a user, but the query is very complex, I’m for a while trying to solve with Queries, but I…
-
0
votes1
answer999
viewsIf exists update Else Insert in table with foreign key postgres
I need to do an Insert in a table with a foreign key, so if this record does not exist in the other table I need to do an Insert, can I do this operation using if exists? Some solution?
-
0
votes1
answer43
viewsStatement of 2 PK Sql
Good afternoon. I have the table Icms that has as PK the columnIcmClaFiscal, need to pass the column IcmEmpresa also as PK, but SQL gives me an alert. As I have been able to do this procedure in…
-
0
votes0
answers48
viewsProblem Related DB
I’m making a system in C#, connected the database (Access) and the program asked to copy the database to the system folder and everything else. The problem is that the application is not saving the…
-
0
votes1
answer34
viewsCombobox and Sqlreader
I have a ComboBox with a list of items containing names that are generated from my database (I pull up the name of coluna beer that are allocated in the table): private void Form1_Load(object…
-
0
votes1
answer1049
viewsDatadirectory C#
I need a flexible connection string so that it automatically searches the program folder for file . mdf. My following code is like this: public Form1() { string relative = @"..\..\Database1.mdf";…
-
0
votes0
answers65
viewsSelect prioritized and ordered by field
Well I have a schedule schedule table and I need to display the announcer who is live at the moment, I’m picking up via php the dates and playing in select but several times leaves or disorderly or…
-
0
votes1
answer1092
viewsHow to get the current date minus two years in mysql?
I need to show in a query some items between the current date of the time in question and two years before.
-
0
votes0
answers275
viewsCode Igniter - How to call a precedent that is in another database?
I have an SQL Server where we have several Databases and their schemas. So far so good, but I need access to a stored database. I tried it :…
-
0
votes2
answers2053
viewsSearch Records that are not in another table
Good morning.. I have the table [BCT_PESSOA] with PK [ID_PESSOA] this table has relationship with the table [BCS_USUARIO] with the column [ID_PESSOA] I would like to return all records to the table…
-
0
votes1
answer37
viewsCharacter Explosion in Oracle
I have the client base, and the client base: COD CLIENTE 128 JOAO 129 MARIA 130 DULCE NOTA 234.123.334.128.50 235.124.338.128.49 Note that the client code is inserted in the note number, which in…
-
0
votes2
answers423
viewsCheck if the record already exists, if it exists does not change the value (MYSQL)
PHP functions <? if($_REQUEST['salva_ed']){ $sqlu="update registration set username='$username', firstname='$fname', lastname='$lname', sex='$gender', birth_date='$bdate',…
-
0
votes1
answer28
viewsCreate condition in instruction
Hello, I have the following select: SELECT CONSTRAINT_NAME FROM user_cons_columns WHERE COLUMN_NAME = 'CANCELAMENTO' and table_name = 'NAVIO'; After picking the name the same goes to another query…
-
0
votes1
answer982
views -
0
votes2
answers183
viewsSelect in Sql Server
Good morning. I have a table with columns Version, Updated, LastChanged. I want to make a query to select the highest version value, with the respective LastChanged, corresponding to Updated = 1; I…
-
0
votes1
answer345
viewsMy Sqlserver Express 2014 does not show all installation options
I formatted the PC and I’m trying to install the Sqlserver Express 2014 accompanying a tutorial on youtube, but when it comes to this point of the instation mine does not come all options equal to…
-
0
votes1
answer67
viewsView photos by Repeater with sql server Using split
I’m not able to upload the photos in repiter making a carousel coming from the data bank, I can not find anything on the web related to this problem follows the Cod ASPX Imoveldetail <section…
-
0
votes2
answers37
viewsCount Out of a Ranking
I have a movie ranking system on my website and I need it NAY show how many users recommended such a movie, here’s my code : $query = "SELECT DISTINCT filmes, count(filmes) FROM filmes_rec GROUP by…
-
0
votes0
answers58
viewsSelect last conversations by counting unread messages in each conversation
I have done a chat in Nodejs and I can already bring the list of conversations. However, I also need to bring the amount of unread messages from each conversation. Currently this query brings the…
-
0
votes0
answers58
viewsHow do I make two references of a table in other 2 tables?
Well, I have 3 tables tbl_users tbl_article tbl_profile I need tbl_usuarios to be related to tbl_articles and tbl_perfil. How could it be done? Table tbl_usuarios:…
-
0
votes1
answer93
viewsWhat is the "function" in Oracle equivalent to a "set Generator"?
I’d like to know, what is the command on Oracle would be equivalent to SET GENERATOR GEN_ID_TABELA TO 5; (command made in FireBird) Because I would like to create a script with the inserts, but to…
-
0
votes1
answer307
viewsHow to concatenate data from a Datagridview and Save to a single database field
I want to concatenate and save the fields of a datagridview, but I don’t know how to do it. What I Have: method: public void Gravar() { string strQuery; strQuery = "INSERT INTO Prato"; strQuery +=…
-
0
votes2
answers819
viewsCommunication between javascript and PHP
Hello, I’m a beginner in php and javascript and I’m having trouble creating iterative tables. In my case, I have an initial table: When selecting the line that I want to check in more detail the…
-
0
votes1
answer36
viewsOracle - From/to Webfocus for Oracle
Guys, I’d like some help. I have an ETL that was created in Webfocus, and I will migrate it to Oracle. I’ve done a lot of/stops, and would like an alternative to the following situations. In…
-
0
votes0
answers52
viewsAgenda with SQL (slowness)
I have a commercial management system and a much used module is the agenda. The programming (.net+Sql) worked very well, but now the table has about 1M of records, and is becoming almost impractical…
-
0
votes1
answer640
viewsHow to select the records of a high box table in postgres?
I need to select all records from a table where the letters of a given column are in the upper case (Uppercase). Is there a function that does the case/minuscule differentiation in POSTGRES? Here is…
-
0
votes1
answer79
viewsQuery with datiff returning 0 in sql server result
I have the following appointment: SELECT DATEDIFF(hh, MIN(BATIDA), MAX(BATIDA))AS HORAS FROM ARELBATIDATRANSITOVIEW WHERE CHAPA = 3187 AND BATIDA IS NOT NULL AND SEQUENCIALBATIDA IN (2,3) GROUP BY…
-
0
votes2
answers45
viewsA separate city sql query
My Brand Sales Chart: City for which the sale was made, date and time of sale. I would like to pull all sales sorted by date and time, but with a specific separate city. For example: For sale 12 -…
-
0
votes1
answer288
viewsHow to make a change to "Cascade" using oracle
How can I change my table ID BANDAS_E_ARTISTAS and ensure that other foreign tables also change via PL/SQL? TABLE BANDAS_E_ARTISTAS ID NOME_ARTISTICO 01 RAÇA NEGRA 02 OS MENUDOS 03 KELLY KEY 04 LUIZ…
-
0
votes1
answer697
viewsSubtract a sum value (SUM) from SQL?
Good afternoon! I have an SQL query, which searches and sums up the amount of credits a given user has: SELECT *, SUM(quantidade) as total_creditos FROM creditos INNER JOIN usuarios ON…
-
0
votes2
answers301
viewsDirect subtraction in a view query?
I have the view dbo.ViewExportItensNotasFiscais, have the field NFValIcmsSubs, where it is necessary to subtract the field value NFValFCP and keep the column name as NFValIcmsSubs How could I do a…
sqlasked 7 years, 5 months ago Igor Carreiro 1,917 -
0
votes1
answer202
viewsReturn data from an N:N table only with foreign keys
Good afternoon, I am inciante in SQL language, and I’m wondering how to return the values of foreign keys in a relation N:N example, return the product name and the part name. Grateful from now on.…
-
0
votes3
answers899
viewsNOT EXIST ? How to use
Person, I need a help, need to filter only people who have X, Y and Z plans that are not on the other table For example: I have a table of plans, where within it has 50 plans, however, only 5 have…
sqlasked 7 years, 5 months ago Wesley Giovedi 1 -
0
votes2
answers4115
viewsQuery returning error in query between date period
Consultation: SELECT ROW_NUMBER() OVER(ORDER BY V.DATA ASC) AS ID, V.CHAPA AS CHAPA, F.NOME AS NOME, V.DATA AS DATA, CASE WHEN V.BATIDA IS NULL THEN 0 ELSE V.BATIDA END AS FOLGA FROM…
-
0
votes2
answers209
viewsRelated tables: What is it? What is it? What is it for? What justifies its use?
I would like a better explanation of this strategy (if so called) and what justifies its use since I see some commercial systems using it. Supplementation of the question: Well, I had never seen it…
-
0
votes0
answers138
viewsSearch Mysql record without using ? id=id in URL
Guys, I’m trying not to use $_GET[] on the link, but I can’t find any way to make it happen. I mean, instead of "site.com/? post=name news" stay "site.com/name-news". I’ve already reviewed forums…
-
0
votes1
answer64
viewsSearching for data from an ID in DB
I did a search here and on google to see if it would solve my problem without having to ask a question, but I could not find any solution. What I am trying to do is create a "related" but without it…
-
0
votes1
answer401
viewsFloat variable with 2 digit accuracy after the comma in sql oracle
How do I create a float variable with 2 digit accuracy after the comma in a table in SQL/Oracle. From now on, thank you.
-
0
votes0
answers103
viewsHow to make an SQL query via Socket?
How to get the client to pass a query to the server and then return what the client requested? Example: Client passes the server to string: sql = "Select nome From Aluno"; and the server would have…