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
answer60
viewsI have this code, how to update in sql?
have tried $sql = " UPDATE biblioteca SET nome_usuario WHERE nome_usuario IN ( SELECT nome_usuario FROM ( SELECT nome_usuario, COUNT(id_usuario) FROM orders WHERE nome_usuario )" $sql = "UPDATE…
-
-2
votes1
answer31
viewsVariable with different values for each while return
My problem is that the $buy variable has different values with each while return, and I don’t know how I select which one is the smallest while($dados=mysqli_fetch_array($result)) { $idenc =…
-
-2
votes1
answer415
viewsADODB.Recordset error '800a0e79' Operation not allowed when object is open
ADODB.Recordset error '800a0e79' Operation not allowed when the object is open. /intranet/portal/sistemas/MAN6/includes/inc_cmbDropSituacaoReserva.Asp, line 12 <% sql="select id, nome from…
-
-2
votes1
answer658
viewsSQL Server does not connect to SQL Management Studio
Guys, I’m just coming here because I’ve tried everything, all the steps on the Microsoft site for this kind of problem I’ve tried, downloaded SQL Server 2017 and later downloaded Microsoft SQL…
-
-2
votes1
answer206
viewsInitialize a Node.js server and connect to MS SQL
I’m starting to use Node.js and developing web applications, I believe this is a very basic doubt, but I found nowhere a solution to my problem. I need to connect my . js with MS SQL, found the…
-
-2
votes1
answer39
viewsError in PDO embedded
Hello, I have the following code: public function insert($nome,$email,$senha,$cluster,$situacoes_id,$niveis_acesso_id,$empresa,$modified,$area,$escritorio,$contrato,$regional) { $stmt =…
-
-2
votes1
answer177
viewsGet last ID value and add +1 in SQL Database
I’m new to this language, I was previously using a auto_increment to save the ID sequentially in the bank, but found problems in other functions. My question is: How do I get the last "id" of the…
-
-2
votes1
answer42
viewsHow to increment primary and foreign keys in Postgresql using SERIAL
I can’t automatically increment primary and foreign keys of my tables using SERIAL, because error happens and always have to enter the key value. create table cliente( cd_cliente serial primary key…
-
-2
votes1
answer98
viewsHow to join fields from a php array
Good evening, so I’m facing a problem with an array, my idea is the following, create an array $MESA[IDMESA] and within that array I would have all information about a particular table that is…
-
-2
votes1
answer28
viewsHow to identify weekly clients that appear in one table and not another in sql?
Hey, all right, guys? Well, I need to identify weekly clients who have an active plan but didn’t use the plan that week. I have two tables, one that contains the type of client’s plan and another…
-
-2
votes1
answer38
viewsInner Join with 3 different tables and Joins
Greetings, I need to make a query in the database that takes into account 3 tables. We use a proprietary application that has no automatic update, so I need to monitor who is not with the latest…
-
-2
votes1
answer113
viewsHow to catch two tables without joining them with Zend1.12 query Builder?
Based on documentation of Zend 1.12, using the Builder query: How I select two tables with comma only without joinInner: Example: SELECT TABELA1 FROM ( BLABLABLA... ) A, (SELECT TABELA2) B To…
-
-2
votes1
answer136
viewsProblem selecting month with Chart.js
Hello, I’m having a problem, maybe I’m not doing it properly, but, come on! I use a chart with Chart.js, I managed to bring the sql data of the desired month normally, it is communicating and…
-
-2
votes1
answer35
viewsGet SQL data for Select
a forum recommended using this schema to take the data from an SQL column and bring it to select. However, when I submit the form, what is being sent is the id_project and not the project name_name.…
-
-2
votes1
answer41
viewsWarning: mysqli_real_escape_string() expects Parameter 1 to be mysqli,
I’m trying to make a record but is giving an error shown below. Notice: Undefined variable: conexao in C:\xampp\htdocs\telecom\cadastrar.php on line 4 Warning: mysqli_real_escape_string() expects…
-
-2
votes1
answer72
viewsSQL code with php PDO bindValue returns a simple quotation marks inside the IN in SQL
Next, I am developing a fuel system, specifically in the part of filters for generating a custom report it returns me an IN('1,2,3') with simple quotes It all starts in the form, in which I have a…
-
-2
votes1
answer38
viewsI make a query in the database through concatenations in my query and returns empty
I make my query in the bank with the following function and is not returning anything. function pesquisarPaciente2($nome_paciente = "", $nascimento_paciente = "", $id_paciente = ""){ global $pdo;…
-
-2
votes2
answers74
viewsproblem in sending php form data to Mysql database
Hello, I am beginner in PDO and in my development of a form I can not send anything to the database and I can not identify the problem in my php form, someone could help me please? FILE…
-
-2
votes1
answer40
viewsSQL Server Query
can help me with this consultation? CREATE TABLE Region ( idRegion INT PRIMARY KEY IDENTITY(1,1) ,cdRegion VARCHAR(50) ) CREATE TABLE Store( idStore INT PRIMARY KEY IDENTITY(1,1) ,cdStore…
-
-2
votes2
answers630
viewsHow to put a PHP code inside an HTML that is stored in a PHP variable?
I am a beginner in PHP. My intention is to create a variable that will store snippets of a DIV in HTML. However, some excerpts of this HTML contain PHP instructions, and I don’t know how to make…
-
-2
votes1
answer94
viewsError 1064 Mysql Workbench
I am a student of Analysis and Systems Development, and I am having trouble with the creation of the script below: the error shown is as follows:: Error Code: 1064. You have an error in your SQL…
-
-2
votes1
answer95
viewsDjango is not saving users in the database
I’m doing a project with Django and using postgresql as a database. I created an app Accounts for user registration, but is not registered in the database and does not appear in the Django admin…
-
-2
votes1
answer42
viewsDifferent performance using limit less than 100 and greater than 100
I have a subselect that filters 16 records and there is a limit of 100. This consultation results in a time usually of 1:20 ~ 1:40 minutes. But when I change the limit to a number greater than 100,…
-
-2
votes1
answer256
viewsUnknown column in 'field list' in INNER JOIN code using COUNT()
My SQL code has the following error: Error Code: 1054. Unknown column 'venda.cd_venda' in 'field list' Does not return the count of the records I want for me to filter them into a…
sqlasked 4 years, 1 month ago Matheus Santana 1 -
-2
votes1
answer42
viewsCALCULATION TIME (SECONDS) BETWEEN TABLE FIELDS
good afternoon! I need to calculate the time in seconds of results from the same table/column, only different Status. SELECT e.nm_paciente, e.ds_idade, e.ds_sexo, e.NR_PRONTUARIO, e.DS_ANOS_MESES,…
-
-2
votes1
answer35
viewsBase Bi - MYSQL
It’s a layman’s question for being a situation I hadn’t encountered before. I have an instance of RDS Mysql with at least 22 databases. The current company needs to build a bi-model to consume the…
-
-2
votes1
answer56
viewsCASE RETURNING MORE THAN ONE LINE IN A SUBCONSULTA
I’m having a problem in a sub-sale that returns me the payment type (CREDIT OR DEBIT) and whether the payment was in card or not. However, if I have a payment with the two types of card the…
-
-2
votes1
answer192
viewsconvert BLOB image value to.jpg image again
I need to make the code below not show the blob value of the image q was saved in the database, but show it in figure.jpg to list on the screen. how can I convert inside that same code? <?php…
-
-2
votes0
answers32
viewshow to use "SET ARITHABORT ON" in vb6
Good afternoon Personal, I needed to use some commands to concatenate some records in a query... So far so good, I did it that way and it worked: SET ARITHABORT ON; SELECT COALESCE((SELECT…
-
-2
votes2
answers49
viewsHOW TO TREAT EMPTY VALUES IN SEVERAL COLUMNS?
I have a TB that has 15 telephone columns, where several rows are empty. I need to turn these 15 columns into only one. Using UNION ALL and putting a condition in WHERE to get rid of the empty…
-
-2
votes2
answers76
viewsHow to mount this query
I need to return new clients for a certain period, but in the bank I can only work with "anocobranca, mescobranca", to count as a new client I check everyone who hired a service within the period,…
-
-2
votes1
answer129
viewsQueries Mysql database
Currently I have studied SQL Server and My SQL in college, but having a lot of difficulty in making queries in the database. The bank has 3 tebelas (aluno, discuplina and matricula) Show the total…
-
-2
votes1
answer23
viewsUpdate a given table field - SSMS V18
I’m filling a table with data that I pick up in a JSON, as shown in the image: When the markettype is 'place', does not have the correct information of 'Category' and 'Distance'. When the markettype…
-
-2
votes1
answer22
viewsQRCODE Having Ireport Problems
My Qrcode is printing as follows on iReport, this way is in trouble: Correct would be in this format: I have already realized all the necessary configurations for the operation of it. 1 - I added…
-
-2
votes0
answers43
viewsQuery of SQL Count
In a certain algorithm routine, the following data is recorded in a table: Color Changed Led (Are two possible leds, code 2 to yellow, 3 to red) Reason for the Change (These are pre-defined reasons…
-
-2
votes1
answer31
viewsSQL - COUNT and GROUP BY doubt
I have the following question: Select the first name (first_name) and title of the film (film) of all(s) the actors/actors/actresses (actor) associated(s) with the movies of the (Category) comedy…
-
-2
votes0
answers49
viewsProblem sending my HTML form to the database
I am developing an HTML site with the primary function of registering patients, employees, diseases among others. All HTML pages are done, as is the databank that has already been modeled in…
-
-2
votes0
answers13
viewsSQL Msg 2627, Level 14, State 1 Cannot Insert Duplicate key in Object
Hello I’m new still need to migrate some students to another table but gives the error of uplikey Dcate someone can help ? INSERT INTO [base_order_corp].[dbo].LY_HISTMATRICULA(ALUNO, ordem, ano,…
-
-2
votes0
answers23
viewsReturn larger date without repeating ids
I need to return to the highest date without repeating id. I need a table with: Customer id Date of last download Number of text messages sent to the ID Date of last text message Date of the signup…
-
-2
votes0
answers18
viewsSQL - Query to bring two-word messages
You guys, good night. I have a BD (mysql) with some tweets stored in a text column. I’m trying to put together a query that returns messages with certain "compound words," but it’s not working. I…
sqlasked 3 years, 3 months ago leosgoncalves 1 -
-2
votes0
answers15
viewsQuestion about Postgresql 9.5.25 with pgAdmin 3 that comes installed along with it: how to use command line instead of graphical interface?
Use the Postgresql 9.5.25 and along with it comes the pgAdmin 3 installed. However, I don’t want to use the graphical interface of the database. So I go in the same folder as the pgAdmin3.exe is…
-
-3
votes2
answers193
viewsInsert in Mysql does not run
I’m having problems with SQL when making a small insertion in DB. I have a table with 4 fields: id_match -> int id_usuario1 -> int id_usuario2 -> int situation -> varchar(5) When I do…
-
-3
votes2
answers712
viewsSelect separated by semicolon to xls
I have the following code: var cmd = @"SELECT mt.Id + ';' + mt.Nome + ';' + mt.Cidade AS Resultado FROM MinhaTable mt"; var objectContext = ((IObjectContextAdapter)db).ObjectContext; var result =…
-
-3
votes3
answers3337
viewsINNER JOIN is duplicating record
I have an INNER JOIN that is duplicating records in the view. Because in the database such records are not duplicated. select conta.dominio, conta.id, conta.modelo, imoveis.id, imoveis.cod,…
-
-3
votes2
answers62
viewsco-pilots who made the most flights
I have this question: Name and number of flight hours of the copilot who made the largest number of flights. It is intended to know the exact number of flights made by each of these copilot And I…
-
-3
votes1
answer129
viewssyntax error, Unexpected 'if' (T_IF)
What’s the mistake? $sql = "SELECT item1, item2, item3 FROM tab_exemplo WHERE" if (isset($item3)) {echo 'quartos LIKE :A';} if (isset($item2) || isset($item1) || isset($item4)){echo 'AND'} if…
-
-3
votes1
answer57
viewsSQL Database
Hello! I am in training in Support and I’m having difficulty understanding the logic of select, I need to make script for example: bring the status of the table Criteria.
-
-3
votes1
answer61
viewsSQL error while trying to Update with PHP
public function AlterarDoador(ClasseDoador $AlterarDoador) { try { $pdo = conexao::getInstance(); $sql = "UPDATE doador SET nome=?,cpf=?,datadenascimento=?" .…
-
-3
votes1
answer881
viewsReturn of duplicated SQL results
I have the following SQL SELECT `inte`.`int_nome`, `age`.*, `con_at`.`con_nome` as consultora_que_atendeu, `con_ag`.`con_nome` as consultora_que_agendou FROM (`agendamentos` as age) JOIN…
sqlasked 8 years, 3 months ago Sr. André Baill 6,946 -
-3
votes1
answer45
viewsSending data to another table
Hello, I need some help I need to get data using Where to pass to another table : http://image.prntscr.com/image/712077abe80f4033a016675279a7a0dd.png (table of accounts ) In print, shows the "…