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
answer664
viewsQuery to separate records
Good afternoon guys, I’m having trouble performing a query. Have the following table I would like to make a query that shows which and how many status_telefonia had by phone and date, then create a…
-
0
votes1
answer56
viewsWindows Scheduling System ,SQL
How do I create and run a sql(postgresql) command on the windows scheduling system? My problem. I have a postgresql database where I have two tables. One is client and the other is disk lease. I…
-
0
votes0
answers964
viewsCase nestled inside another case
I’m very doubtful about CASE NESTED I have to perform an interest calculation that depends on some variables and I’m not able to build this case, so I need your help to assemble it. 1º IF…
-
0
votes1
answer80
viewsMysql query with mixed ORDER BY?
My doubt is a little boring to explain but I’ll try to make it as simple as possible. I have the following tables in a Mysql database: produto, preco, preco_produto (many mapping to many), venda and…
-
0
votes2
answers1769
viewsExecute SQL command in the terminal
I’m wanting to run sql command through the Windows prompt but I don’t know what the initial settings to do this. Can anyone tell me? Detail: It has to be in the windows terminal.
-
0
votes1
answer43
viewsHow to limit a JDBC connection to only do "select" queries?
I wish my JDBC connection didn’t make queries that can make changes to tables (Insert, delete, update, drop). There’s some way this can be done?
-
0
votes1
answer130
viewsRails and simple_form, filter values to fill a combobox
There are three tables, one call enterprise, another group and a call subgroup, there is a field loan in this two, the last has the field group_id, a form, in this form use the simple_form to show a…
-
0
votes1
answer211
viewsDynamically add sql query value in variable
I have a table (employees), where I want to take the value of id_funcao, id_percentage and put in this variable $percentage. Not only do I want to put the 30%, but the values of the Percentage…
-
0
votes1
answer48
viewsSQL with PHP - SELECT problem
I have an album, as soon as I click on the album, is to appear only the photos that are in the database with the id of the selected album, I click on the album and this coming the photos of the…
-
0
votes1
answer32
viewsSelect - Time comparison does not work
I am trying to make a query to eliminate results in which the end time of the event is equal to 00:00:00, I made the query this way: select nome, local, hora_inicio, hora_fim, data_inicio, data_fim…
-
0
votes0
answers158
viewsMysql query problem (subquery) difference between MYSQL versions.
I have a problem in a MYSQL query, I think it is different from versions of MYSQL, my client’s database is on hostgator (Database client version: libmysql - 5.1.73 / Server version: 5.6.30 - Mysql…
-
0
votes0
answers157
viewsHow to install sqlsrv driver on Pdo?
How do I install or sqlsrv driver on Pdo? <?php function conectar(){ $pdo = null; try { $opcoes = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION); $pdo = new…
-
0
votes1
answer119
viewsgroup per SQL query
I have a table post with a field category, each post that is inserted may receive more than one category: post1 categoria1, categoria2 post2 categoria1, categoria3 how can I perform an sql query to…
-
0
votes2
answers158
viewsQuery to return specific values
On my table IDENTIFICACAO_PESSOA I have a column called IDENTIFICADOR. This column receives CPF values. However, there are values there that do not correspond to CPF, that is, they are outside the…
-
0
votes1
answer896
viewsAccess function equivalent to COALESCE
Hello. I’m trying to build an INSERT with auto numbering in Access, but I’m not getting it. In SQL Server, Mysql and Postgres I use the COALESCE function, but I can’t find this function in Access.…
-
0
votes1
answer46
viewsHow to add many customers at once in a database table?
I need to add Name, Phone and Address of many clients who are in excel and pass this to the database. What would be the fastest way to do that ?
-
0
votes1
answer577
viewspostgres compare time extracted from a timestamp
I need to extract the hours and minutes of a timestamp in mysql, I tried to use maketime(); CREATE OR REPLACE FUNCTION agendar(dia timestamp) returns bool as $$ declare hora time := extract(hour…
-
0
votes0
answers66
viewsmysql error while trying to insert a timestamp
I’m trying to pass a timestamp per parameter for a Function, but I end up getting an error ERROR: invalid input syntax for type time: "10" the stretch where I pass is: select agendar('2010-01-01…
-
0
votes1
answer669
viewsoccurrence of word in sql query
I have an appointment SELECT NOME FROM PESSOA WHERE CODIGO = 1 She returns to me ANA ANA JOAO ANA ALBERTO ANA There is a way to count the events of ana? Using only the sql query?…
-
0
votes0
answers80
viewsWhen I run Update the eclipse for execution
When arriving at the part that executes the following query the system stops and does not proceed to the next line. @Query(value = " UPDATE COOBILING_NUMBER SET CONDITION='Used' WHERE NUMBER_PHONE=…
-
0
votes0
answers37
viewsFix Incorrect Email Records
I need to fix via PHP programming, incorrect emails registered in our database. Would be emails without domain, with space in any position, with ". @", "@." without "@", any character not allowed in…
-
0
votes1
answer204
viewsSelect two hour fields where one of them goes past midnight
I have two tables with the following scheme: data | hora ini | hora fim -----------|------------|--------- 16/08/2016 | 1115 | 1319 16/08/2016 | 1320 | 1419 16/08/2016 | 1420 | 90 Being that in the…
-
0
votes1
answer124
views -
0
votes1
answer235
viewsIs it possible to use the same column name as a parameter name on a cursor?
I have the following cursor: -- CÓDIGO OMITIDO DECLARE CURSOR CUR_AULAS(IDTURMA NUMBER) IS SELECT ID, IDCLIENTE FROM AULAS WHERE ATIVO = 1 AND IDTURMA = IDTURMA; It will always return true because…
-
0
votes1
answer1114
viewsError creating a simple table in Oracle SQL Developer
I’m having trouble creating the following table: CREATE TABLE T_AM_OME_ADVOGADO ( cd_pessoa NUMBER (8) NOT NULL , nr_oab NUMBER (8) NOT NULL , nr_cpf NUMBER (11) NOT NULL , nr_rg CHAR (10) NOT NULL…
-
0
votes2
answers527
viewsFormat date when performing Update in the registry - Postgresql
I am saving in my database the date that certain record is changed, however the format that it is saved is (YYYY-MM-DD), the SQL command used so far is as follows:: update public.transportadora set…
-
0
votes0
answers63
viewsdata listing
he’s just printing the first line of the database and I want you to print out all the lines . <?php @session_start(); include_once $_SERVER['DOCUMENT_ROOT'] .…
-
0
votes1
answer224
viewsrelationship between SQL tables
I have the following problem, I have two stocks in my company, so I have two values for the stock, and the stock record looks something like this: as the picture shows, each product has two records,…
-
0
votes1
answer120
viewsLeft Join returning only certain fields
I have the following tables: tb_agenda id_agendaid_medicdatehour tb_patient id_patientpatient name tb_medic id_medicdoctor’s name tb_scheduling id_schedulingid_agendaid_patient I make the following…
sqlasked 7 years, 8 months ago Sergio Silva 93 -
0
votes1
answer2205
viewsSelect using Join with Distinct
I have two tables: tb_movement | cod | dt_producao | qt_prod | |-----|--------------|---------| | 1 | '04.08.2016' | 10 | | 2 | '04.08.2016' | 5 | | 3 | '09.08.2016' | 12 | | 4 | '10.08.2016' | 3 |…
-
0
votes1
answer32
viewsDoubt in SQL Table
I created a table: Tabela Curso: Id int auto_increment nome varchar; Insert: Default, Arquitetura; Architecture has the ID 1 in the table. I delete the course Architecture. When I add any other…
-
0
votes1
answer605
viewsSum mysql decimal values
I made a query that adds a decimal field, only I’m having trouble, because when I put the clause group by t1.id_sell it lists me sales but no longer sums correctly and without the correct sum clause…
-
0
votes1
answer202
viewsORACLE RANK() function
Could someone explain me what is wrong with my syntax/use of the RANK function? Problem situation: "Rank songs by band so that songs of higher duration occupy the first places. Present band name and…
-
0
votes2
answers717
viewsSearch and people who have the same name, surname and date of birth
How can I perform a select on Oracle that brings all people who have the same name, surname and date of birth however, have different ID’s.
-
0
votes0
answers41
viewsHow to take the day
I need to take only the "day" of the person’s birthday in SQL. include("conexao.php"); $mes = date("m"); $consulta = $conn->query("SELECT * FROM niver WHERE niver LIKE '%".$mes."%'");…
-
0
votes1
answer27
viewsSelect some data from different tables
Reborn the programmer around here, I’m having trouble with SQL and ask for help. I have two tables called orcamentos and clientes. I need to select all fields in the table orcamentos and only the…
-
0
votes1
answer165
viewsDisplay return of an SQL query in Excel
My question is divided into two parts. The first, it is possible to perform SQL command by Excel, because I need to display certain information from my Mysql database in an Excel table. Observing: I…
-
0
votes0
answers338
viewsLaravel Query Builder returning duplicate values?
I have the following problem, I have a select using leftJoin, more is returning duplicate records, the bank is not duplicated and when shooting the leftJoin works. Follows SQL Tabela processo…
-
0
votes1
answer61
viewsSelect from different tables
How to select from different tables? Type, check if there is value in one, if not, check in the other.
-
0
votes1
answer40
viewsError trying to create a Proc in the bank
I’m trying to run a stored procedure in the bank and it’s giving this message: Cannot Grant, Deny, or revoke Permissions to sa, dbo, Entity Owner, information_schema, sys, or yourself How do I fix…
-
0
votes1
answer1553
viewsPopular table in sql server with data coming from an excel spreadsheet
How I create a script or via DTS, a popular form of a table in the sql server 2014, with information from a spreadsheet of excel? The worksheet has several columns, but only two columns will be…
-
0
votes1
answer253
viewsWaiting for table level lock Mysql Java application error
I have a Java swing application that uses the Mysql database, in its operation after spending some time in operation I realized that the application hangs in a few moments, It is necessary to…
-
0
votes2
answers79
viewsComplex wp_query
I am setting up a schedule of events in Wordpress and need to list all the events of the week grouped by current day. I have events that last only one day and others that last all month. I created…
-
0
votes2
answers206
viewsInsert query does not work in PHP
I have the following query that is not working in PHP, because I run in SQL does not present any problem. sql= "INSERT INTO books (ISBN, Authorsname, Title, edition, year, publisher, category,…
-
0
votes2
answers950
viewsCalculate Value of SQL columns
I have two tables BMV_PEDIDO and BMV_PEDIDOITEM and would like the total sum of the value of the orders made on a given date. I currently make this request per request, ie, I replicate this code…
-
0
votes1
answer59
viewsList data from 2 tables linked to the parent table
ORDER TABLE --------------------------- | id_pedido | pedido_data | --------------------------- | 1 | 2016-01-01 | --------------------------- TABLE PEDIDO_ITENS…
-
0
votes2
answers364
viewssql inserts the wrong datetime into the table
i to using microsoft sql manager,and was trying to insert a date in my table,the problem is that it is entering the wrong date,i do the following command for the manager table INSERT INTO tblCliente…
-
0
votes2
answers842
viewsAverage per hour Mysql
Hello, I wonder if you could return only the averages per hour of a table as below: id | valor | timestamp | 1 | 5.4 | 2017-4-20 18:00 | 2 | 3 | 2017-4-20 18:01 | 3 | 2.8 | 2017-4-20 18:40 | 4 | 2 |…
-
0
votes0
answers766
viewsTrigger to update a field automatically after Insert
I have a user table, basically: CREATE TABLE IF NOT EXISTS `sistema`.`user` ( `id_user` INT NOT NULL AUTO_INCREMENT COMMENT '', `hashed_id` VARCHAR(40) NOT NULL COMMENT '', `nome` VARCHAR(40) NOT…
-
0
votes0
answers45
viewsFetch columns from two tables that are not directly related
I have 5 tables: cliente, produto, compra, compra_produto and fornecedor. And the following relationships: compra (fk_cliente) compra_produto (fk_compra) compra_produto (fk_produto) produto…