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
-
2
votes1
answer47
views -
2
votes1
answer30
viewsQuery returning users who have a set of records from another table
I developed a small system in PHP and Mysql that aims to store and manage users and their respective courses. I searched some forums and pages in Google, but I did not find any information to help…
-
2
votes0
answers27
viewsInterconnection of tables in Mysql in Java program
Good afternoon ladies and gentlemen, I am developing a project for study with 2 tables and these tables need to be connected in a certain value. In my package DAO, have 2 classes Stockpile and…
-
2
votes1
answer49
viewsIs it possible to filter an SQL base based on a list of values?
On pandas, when I want to filter one DataFrame based on a list of values, I: valores=[15,17,22] df=df[[k in valores for k in df.mpg]] In SQL I know I can get the same result with the following code:…
-
2
votes1
answer71
viewsSearch for similar names or with typo - Mysql
I am looking to perform a search in a table containing the name of the products. I created a FULLTEXT to optimize the performance of the queries. SELECT * FROM tabela WHERE MATCH (campo) AGAINST…
-
1
votes4
answers1290
viewsHow to bring a specific result of an SQL query above the others?
I have the following SQL query: SELECT DISTINCT `user_id` AS `id`, `user_name` AS `name` FROM `users` ORDER BY `id` ASC; That generates the output: +----+--------+ | id | name | +----+--------+ | 1…
-
1
votes4
answers702
viewsWhat are the best practices of representing SQL within PHP code?
PHP program together with SQL (mainly Mysql) for a long time, I already have some experience, however I never found a good solution for this: what is the best way to insert SQL within PHP code?…
-
1
votes1
answer139
views -
1
votes1
answer538
viewsHow to import MDB file read and write to SQL
I am trying to import a MDB file, read this file and write to SQL. I’m already able to import the file and read, I just can’t yet take this data and write to SQL. If you notice the code I even…
-
1
votes3
answers1619
viewsInsert data Database Related tables
I’m having trouble inserting data that has related tables. $sqlinsert2 = "INSERT INTO tb_detalhe_trabalhador VALUES(0,NULL,NULL,'".$MedicaValidade."',.. Currently the data that are as NULL are the…
-
1
votes3
answers1494
viewsFilter table before applying a LEFT JOIN
I have two tables and I want all the elements of the first - regardless of the condition of JOIN (which characterizes a LEFT JOIN) - but before that I want to filter the second table. For example:…
-
1
votes2
answers9591
viewsHow to avoid SQL Injection in my PHP application?
Explanation: Most applications using PHP, should receive parameters, by $_GET or $_POST and these parameters often become an easy target for users with bad intentions, and this is called SQL…
-
1
votes2
answers443
viewsPaging results in SQL Server 2000
Sometimes I need to make queries in SQL Server 2000 and paginate the results but there is only the clause TOP that limits the number of records returned without an interval (offset) other banks like…
-
1
votes2
answers468
viewsupdate in 2 tables with calculation and field update keeping the previous
People I am trying to do an update taking the value of another table, but the data of the second table is not sent. I’m passing the card ID: <a href=index.php?pag=shopcomprar&id={$row['ID']}…
-
1
votes6
answers708
viewsHow to count the number of clients that returned from one year to the next through SQL?
I have a table Serviços(Nro_Serv, Data, Cliente, Valor) and would like to get customers who did service with me in a year X (ex: 2011) and who also did in a year Y (ex: 2012). I tried to use…
-
1
votes1
answer131
viewsWhat are the SQL formatting standards? Do you have a tool that does this?
I asked a similar question, but about javascript. But I deal a lot with SQL and Mysql codes. Is there a commonly accepted standard? Does anyone know of a tool that validates or modifies the code?…
-
1
votes3
answers4590
viewsSQL use variable in column name
I need to use variables to set the column name in my sql query. Gender: SELECT IDLayout, Nome, @collum, TipoProduto FROM ProdutoLayout WHERE (TipoProduto = @tipo) AND (@collum = 1) Whereas the…
-
1
votes1
answer341
viewsFunction RANDOM in IBM Informix BD?
I need to use an Random() SQL function in a Informix version 11.50 database. But in select below returns syntax error : select random(), codigo from minha_tabela; 674: Routine (random) can not be…
-
1
votes1
answer412
viewsLIKE query in related table
I have a query that searches for TECHNICAL CALLS and in this research I do some JOINS to bring related information. I need the LIKE to also work for the CLIENT name (which is in another table) The…
-
1
votes1
answer195
viewsMap Hibernate classes with Posit-id and joined-subclass
How can I map a class with Composite-id and extend another class? I’m using the example in: http://www.javacodegeeks.com/2012/08/hibernate-composite-ids-with.html I tried to change the code, but…
-
1
votes2
answers2326
viewsFind and replace before and after using an sql wildcard
I have a list of over 5000 cards with different names and one - (hyphen) in common. Example: Evilswarm Exciton Knight LVAL-EN056 Number 101: Silent Honor ARK LVAL-E47 Number 11: Big Eye GAV-EN090…
sqlasked 10 years, 8 months ago Arsom Nolasco 1,367 -
1
votes2
answers240
viewsQUERY with no expected result, what might be missing?
Complementing with current information, I understood the current result, and what it seems is duplicated information even, but in different tables, but this is not even with me because I already…
-
1
votes1
answer976
viewsPostgresql - Add existing values for the current month
Good staff I have a table with column dates of certain records. I know that to sum up the records of a given day: SELECT SUM(CAST(REPLACE(coluna1,',','.') AS DOUBLE PRECISION)) FROM tabela1 where…
-
1
votes1
answer445
viewsGenerating tables in sql-server with Hibernate
I am migrating a Java system to work with 2 or more databases. I created the tables for Firebird using Hibernate without many problems. The second database was not successful. SQL-Server. Because…
-
1
votes1
answer167
viewsFull query of data registered in a field
I have a table where a country field is defined. I want to know how I can develop a query that shows me how many records I have for each country. Example: Brazil: 10 registrations USA: 5 records…
-
1
votes1
answer2201
viewsInsert random data into a table that has foreign keys (Oracle)
I have a table "usuario" (idUsuario, nome, departamentoId) and another table "departamento" (idDepartamento, nome). I would like to enter random data in the user table, but for this, I need to…
-
1
votes1
answer293
viewsUpdate if value does not exist
I have these two tables in the database (SQL Server) Table Banks ID CODIGO NOME 1 246 Banco ABC Brasil S.A. 2 075 Banco ABN AMRO S.A. 3 025 Banco Alfa S.A. 4 001 Banco do Brasil S.A. Table Account…
-
1
votes1
answer13532
viewsC# Select and display in a combobox
I’m creating an application in C# windows Form and wanted to know how to select a table and display a list of clients in a combobox.
-
1
votes3
answers21331
viewsInsert image into database
What type of variable do I use to store an image in the database? And is there a specific command for this? or just enter as any record? I have a product table with the fields: code, name, price,…
-
1
votes1
answer6326
viewsHow to insert an image in Mysql?
I’d like to add images to the table, nothing too complex. I would like to add the directory if possible This bank will not have an interface I’d like to see the image by select, but I don’t think…
-
1
votes2
answers436
viewsQuery SQL condition if
I have a problem in doing a query where I have 3 fields and just one of them is filled that no longer shows this result. Someone can help me do that? select * from tabelas where campo1 and campo2…
-
1
votes1
answer612
viewsProblems with sql in access, incompatible data types
Image of the test/error: I only intend to search the data between a date and another, using: SELECT * FROM tblTRAZA WHERE FECMOV >= '2013-01-03' AND FECMOV <= '2013-01-09'; But I’ve tried…
-
1
votes1
answer1953
viewsDynamic Linq Query between two contexts
I’m trying to return the query sql sequinte but without success. SQL= select IDEstado, COUNT(IDEstado) from PessoaEstado w join Nucleo.dbo.Estado e on e.ID = w.IDEstado where IDPessoaMaster = 46…
-
1
votes1
answer869
viewsChange Method using Java and SQL
I need to make a change in SQL using Java, but I ended up getting lost in logic when making the call and the return to change. Follow the outline of the code. Here is the Main, where the user…
-
1
votes1
answer1813
viewsCreating Trigger to change status once you delete employee
I’m creating a Rigger that the moment you delete an employee she changes the status from 1 (active) to 0 (inactive) then save this change in a table (employees dismissed) to access if you need,…
-
1
votes2
answers95
viewsUser verification
I have a program that has 5 níveis de autorização, the Administrador, Gerente, Operador, Usuário and Convidado. But for each level it gives a different access to the system. Sketch of verification:…
-
1
votes1
answer1427
viewsMaster Detail Fast Reports
I have a report in Fast Report of notes and duplicates / boletos. On date I have 2 DbxQuery, note and boletos. In the boletos I put the master as notes, and used as a filter in the boletos the…
-
1
votes3
answers2710
viewsHow do I create a view in mysql by taking data from 4 or more different tables?
How can I create a view and show the data as below:…
-
1
votes2
answers2482
viewsModification update between two Oracle tables
I need to make an integration between two sws of the house and I need help. I have an integration table (3rd) that will receive the data of a new management, if created or modified. For this, I have…
-
1
votes0
answers53
viewsPrevent SQL attacks via $_POST x-Editable
Is there any way to prevent SQL attacks on $_POST, whereas he gets every kind of value, url, name, date and some special characters. I’m using the plugin x-Editable (former Bootstrap Editable).…
-
1
votes1
answer164
viewsSql Timeout with Webmatrix.Data.Database
Using the Webmatrix.Data.Database namespace, I am having problems executing a query that returns a lot of data, resulting in a Timeout. How can I increase the timeout of this query? Code example:…
-
1
votes1
answer412
viewsHow to use SQL min() with float?
I have the following database table: *Table structure for table `resultados` */ DROP TABLE IF EXISTS `resultados`; CREATE TABLE `resultados` ( `cpf` varchar(14) NOT NULL, `nome` varchar(255) DEFAULT…
-
1
votes2
answers164
viewsWhat is the best type of column to record amount of time?
We usually use Datetime to record a specific moment. But what if I want to record that an event lasted half an hour (00:30) or an hour and fifteen (01:15)? I thought to convert to decimal, so the…
-
1
votes2
answers301
viewsHow to return an int in a Decimal property
I have an SQL string (made by another programmer a long time ago, so I can’t change it) that returns something like this: If it has value in column, returns value, otherwise returns 0 (I would post…
-
1
votes3
answers2037
viewsSuspend function in Firebird
What is the function of suspend in a Procedure in the Firebird?
-
1
votes1
answer1624
viewsHow to create a 1:N and 1:1 relation within the same table?
I have a table for recording images that is used as a foreign key for other tables. The problem is that in one of these tables (PROMOCOES) the ratio is 1:N (a promotion for N images ), while in the…
sqlasked 10 years, 4 months ago Tassio Araujo de Souza 13 -
1
votes3
answers4226
viewsHow to select multiple results in one row
The problem: One of our sites has a messaging system between users, for this we have two tables: one that stores the messages between users and the other with users, follow the structures below,and…
-
1
votes1
answer1525
viewsMap columns of separate tables into a single object and vice versa
Situation 1 I have the following tables, very simple: ....................... And I have the following classes: Client: @Entity public class Cliente implements Serializable { private static final…
-
1
votes2
answers93
viewsmysql organizing database entries
I wondered if it is possible to reorder the entries of a table in mysql, overwriting the deleted entries, and without breaking the other tables. If possible, which command would you use and show me…
-
1
votes1
answer837
viewsDoes anyone know a good program to create mysql database?
Someone knows a good program to create mysql database and then I can send it to phpmyadmin?
sqlasked 10 years, 3 months ago Márcio André 487