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
votes1
answer168
viewsJPQL - SQL query
good night. I have a bean, which has an init() method. One of the objectives of this init is to bring the cycle that was opened according to the course of that user, that is, If there is no cycle or…
-
0
votes0
answers110
viewsDependent checkbox
I have a problem and I was wondering if you could help me. I have a CRUD that registers cycles, these cycles can have many courses. What I wanted to do exactly, is validate the selectsOneRadios when…
-
0
votes1
answer29
viewsError while searching list in MYSQL
I have a problem in my system of sending emails newsletter, when loading the index, where the list of registered emails is loaded, the following error appears: Warning: mysql_fetch_array() expects…
-
0
votes1
answer295
viewsHow can I create a form that has a counter and store the information in bank
I’d like some help. I’m trying to create a page that calculates how much time a person spends on some tasks that will be available in a form, then the person selects the task and click on start…
-
0
votes2
answers6683
viewsHow to order by the largest number of groupings, excluding those who have no more than one grouping?
I need to sort my records by as many as GROUPINGS, that is, I have the SQL below and I need the column TYPE who is being grouped, is ordered from the largest cluster to the smallest, excluding the…
sqlasked 8 years, 8 months ago Gladison Neuza Perosini 861 -
0
votes1
answer409
viewsFilter Records by Month/Year Codeigniter
I have the following SQL structure: CREATE TABLE IF NOT EXISTS `noticia` ( `id` int(11) NOT NULL AUTO_INCREMENT, `id_categoria` int(11) DEFAULT NULL, `titulo` varchar(255) NOT NULL, `previa` text…
-
0
votes0
answers28
viewsERROR when selecting a simulation
I have a subscription problem. I have a screen that recovers cycles that are open according to the course of the user and for each cycle of this already has a simulated saved, ie a relationship.…
-
0
votes1
answer352
viewsFix Where Clause with like null operator that finds data with null parameters
I have a query that is picking up the fields null with the like operator. Let’s see an example in the query below: $palavraChave = null; $consulta = "select * from receitas where receita like…
sqlasked 9 years ago André Nascimento 1,258 -
0
votes1
answer311
viewsSort the Table by the value closest to the parameter passed in stored procedures
how to sort a table according to the approximate value of a parameter passed in a stored previous Ex: let’s say that in a table the name field has the following values: Tiago, Iago and Thiago and I…
-
0
votes1
answer194
viewsMake a table condition type in Mysql
Hello, I am setting up a hotel bank in Mysql and I would like to know how to add a condition for date and time of entry (checkin) and date and time of departure(checkout) specific for there to be no…
-
0
votes1
answer729
viewsSQL - Category & Subcategory
I have a category and subcategory structure. And I need to list all categories, and then their subcategories... But the listing went wrong. I’m using the codeigniter. Structure of the Database: SQL…
-
0
votes0
answers77
viewsProcedure to return route calculation between coordinates via the Googlemaps API
I need to create all the business rules of a system within the database and allow other applications for the purpose of being only a graphical user interface to freely utilize all the functions…
-
0
votes1
answer2628
viewsSql similar to Excel PROCV
In excel there is the PROCV function, where I can get close values by comparing columns. Ex.: A B Nome Dinheiro Maria 200 João 1000 D E F Categoria Min Max Médio 0 200 Alto 201 1000 If I use call…
sqlasked 8 years, 7 months ago Marcos Barbosa 377 -
0
votes1
answer807
viewsConvert the result value of the sql query
I have the query that return me two results where I would like to format it to came in the proper format. How could I do this? select *, sum(valor) as ValorSoma, count(pedido) as QtdPedido from…
-
0
votes1
answer347
viewsFilter data from multiple sql columns
I am in need of help with a database, it would be to do a distinct with several columns, for example: and the exit would be: You could do this on sql server? Thanks in advance…
-
0
votes1
answer76
viewsError: 'Operand type Clash: image is incompatible with Numeric'
When trying to save an object in the database, gives the following exception: org.hibernate.Exception.Dataexception: could not update. [...] Caused by: java.sql.Sqlexception: Operand type Clash:…
-
0
votes1
answer216
viewsImport sql server backup from another server
I can not import a backup (.Bak) in sql generated on another server, says that the database is not equal to what I am trying to import and tals, and I put the same name. Does anyone know what might…
-
0
votes1
answer1456
viewsHow to run Trigger sqlserver
How can I execute a Trigger in unit tests. I have a Trigger I have a Rigger as an example: ***-- Create one trigger with two inserts:*** create trigger trg_I_Table_1 ON Table_1 FOR INSERT as insert…
-
0
votes1
answer101
viewsInsert apostrophes with variables
I am performing a query through a value stored in a variable. This variable is declared DECLARE @it_codigo varchar(max) and gets value from a field ntext from another table, through a previous.…
-
0
votes1
answer70
viewsHow to "truncate" table to restart from the smallest auto increment value
To tabela_A has a field id auto increment. I need to clear the table with something similar to the command truncate only that cleaning only the record from the id = x. For example: id col1 1 A 3 B 4…
-
0
votes1
answer34
viewsParameterizing value to be Encrypted in Query SQL
Currently, the query query that returns results is as follows: SELECT nome, email, senha FROM Professor WHERE email = ? AND senha = HASHBYTES('SHA1','" + senha + "') p.setString(1, email); When…
-
0
votes1
answer131
viewsConnect to Sqlserver using Windows 10?
I am using Windows 10 and have to connect to a Sqlserver 2000 database using the command line in a java application. However, I am receiving an error. run: ClassNotFoundException:…
-
0
votes2
answers47
viewsCount script - Sqlserver
I own the table Telefone , that records the phones they called. I need to make a script that shows the number of phones that called. If a phone calls more than once, it doesn’t count. I need to do…
-
0
votes3
answers87
viewsFix data from SQL database
I want to correct a table field, because I have values like this: 123456789 and I want to change to 1234567.89
-
0
votes3
answers239
viewsPick up a single record for equal columns
I have an example table: produto | supermercado ---------------------------- 1 | 1 4 | 2 6 | 1 5 | 1 8 | 2 7 | 3 I want to get all existing supermarkets in this table, without picking up repeat…
-
0
votes1
answer309
viewsCustomization of datagridview in c#
I’m doing a project and I’m having customization problems in my datagrid, as the information of the two textboxes return in the same datagrid I can’t customize the header of the two, but of only…
-
0
votes1
answer36
viewsQuery with two tables
I’m on a project, I have client table and work. A job has a client. I’ve already listed the tables, but I need to select that from the client id in the work table, return the client name. I have to…
-
0
votes0
answers278
viewsHow to recompile all Views, procedures and triggers in Firebird?
I need to recompile all Views, procedures and triggers in Firebird, not by Ibexpert, but by Delphi XE2, I will pass an SQL, I would like to know how to perform such a procedure.
-
0
votes3
answers645
viewsSQL Server subquery is always returning null. How to fix.
I have a Procedure and a COMMON TABLE EXPRESSION(subquery). This my CTE does a search and offers to my query the result, my query then uses the results of it. In my table Address I have a field…
-
0
votes2
answers1627
viewsGenerate random name in Mysql - Stored Procedure
Good evening, is there any way to generate random names with stored data in Mysql? I have the following table: STUDENT(id:int[PK], name(varchar(100)), age: int, Cr(float)) I need to popular this…
-
0
votes0
answers51
viewsOnly get the bank’s final value
I’m using the php with Pdo to query a database in postgress. Is there any way that when you do the query, show the result without having to enter the table name, since select is unique? select…
-
0
votes1
answer31
viewsInstance error for class
Good afternoon, I’ve looked at it many times and I don’t understand why it’s wrong. I need to instantiate the "created variable" that is in Jframe for the User class. But it keeps saying that on the…
-
0
votes1
answer58
viewsDoubt SQL tables
In the 1:1 relations I have done in another way that only today I noticed, in which I turn this 1:1 to 1:N, and in the table that has the N, the primary key is the same as the 1, so it’s like 1:1,…
sqlasked 8 years, 6 months ago programmer2016 545 -
0
votes1
answer80
viewsQuery in SQL Server
When doing the sequinte query select * FROM conta It brings me the columns, being that the id_fornecedor comes from the table fornecedor id | id_fornecedor | conta_status 1 | 1 | S I would like to…
-
0
votes0
answers31
viewsError in SQL code subconsultation
My mistake is this Warning: mysql_fetch_array() expects Parameter 1 to be Resource, Boolean Given in C: xampp htdocs BD project proj_details.php on line 25 <?php $base_dados = "crowdfunding";…
-
0
votes2
answers438
viewsHow to consult with Where and like between two tables?
Guys, I have the following problem: I have two tables, the following tables : tabela mensagens +----+-------------------+-------+---------------------+ | id | mensagem | _de | hora |…
-
0
votes1
answer58
viewsGroup function does not work
I have two tables. Table: Pedido Columns: IDPEDIDO, CLIENTE, DT_PEDIDO, FORMA_PGMT, CLIENTE_ID. Table: Itens_Pedido Columns: PEDIDO_ID, QT_MERCADORIAS, MERCADORIA, MERCADORIA_ID. I need to create a…
-
0
votes1
answer42
viewsdate manipulation in postgresql
I have a database with several records, since 2001 until 2010. How do I select all tuples with dates after the day 2001-05-02? Data is of the type character varying(254).…
-
0
votes1
answer68
viewsIncrease sql performance
I have this function below that runs this SQL, but the running time of this SQL is too high would have some way to decrease the running time ? At the time of loading the page takes around 5 seconds…
-
0
votes1
answer106
viewsHow to do a SELECT pull Qtde or sql weight to a single column on the grid depending on registration?
I have the following question, I created a stock table in sql for packaging and raw materials, with registration in the same form. I created a line for weight and another for Qtde in sql. And I…
-
0
votes1
answer44
viewsDatabase - table list
Personal as I can list all the BD table and put in a table, list or in any one corner of the page?
-
0
votes0
answers65
viewsSQL error in your SQL syntax
I am importing an sql with the following code: CREATE TABLE blog ( id INT PRIMARY KEY AUTO_INCREMENT, title VARCHAR(250) NOT NULL, body TEXT NOT NULL, url VARCHAR(250) NOT NULL); But is returning…
-
0
votes1
answer48
viewsCreate a Three Table Viewer
How to create a view in mysql with 3 tables being the following structure cliente |id_cliente |nome_cliente produto |id_produto |nome_produto |valor_produto pedido |id_pedido |id_produto |id_cliente…
-
0
votes0
answers96
viewsSchedule sql server 2014 job
I have a trial that I would like to run every X time. I have scheduled everything in sql agent. My question is this, I need to replicate this process in all bases to be able to use with the command:…
-
0
votes1
answer448
viewsHow to Select a table row and display information in another table relative to the table?
I’m using this code, but I’m not connecting it properly... I would like to register Payments (payments) for these to appear only when selecting the partner in the table(socio)... String sql =…
-
0
votes1
answer223
viewsHow to create this process
I have these two tables in the bank cadcha (Cadastro de chamadas) cadram (Cadastro de ramal) All calls made in a particular company will be saved in this table cadcha. The destination extension…
-
0
votes1
answer1368
viewsHow to find Null values without specifying attribute (Mariadb)
I would like to do a search to find NULL values across the table without having to determine which of the attributes might contain NULL. NOTE: By ALL table I mean that somewhere in it you have null,…
-
0
votes1
answer75
viewsCalculate time interval in SQL
I have a table where I have 2 fields horainicio and horaafinal I’m wanting to get the results that fits between the initial and final values but unsuccessfully follow what I’m using. I’m taking the…
-
0
votes1
answer257
viewsHow do you set the order by command?
I typed the following command in the oracle; select * from emp where ndep in(10,30); and had it as a result; he’s all right, the problem is I wanted to put him in the descending order of the…
-
0
votes1
answer340
viewsHow to create C# method to do 2 Query SQL Insert?
To create a c# method to insert data, this method does more than one INSERT behind the other? 'Cause I tried it here and it didn’t work out!