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
-
-1
votes1
answer348
views -
-1
votes1
answer67
viewsProblem with PHP in the edit form
Guys, I need some help. I’m doing a PHP job, but I can’t edit it through the form or log in. edita-usuario.php / <?php session_start(); include "conexao.php"; $id = $_GET['idusuario']; $sql =…
-
-1
votes1
answer36
viewsI would like someone to help me with an excerpt of this SQL and Python code
I’m trying to capture a flag of the site Hacker101 CFT and I came across a code snippet. IN THAT SPECIFIC PART: if cur.execute('SELECT password FROM admins WHERE username=\'%s\'' %…
-
-1
votes3
answers212
viewsRelational Algebra - Query in 3 tables
Good afternoon,I’m having a hard time returning a value from my bank when it has two attributes, I’m starting from this statement. Select the names of the parts that use the materials with the names…
-
-1
votes2
answers142
viewsI need to make php only show the last 10 news
<?php session_start(); include "conexao.php"; $sql = "SELECT * FROM noticia ORDER BY id DESC"; $noticia = $conn->query($sql); $conn->close(); ?> <?php include "include/header.php"…
-
-1
votes1
answer49
viewsShow only 1 secondary table record along with primary table on cursor
I have a cursor where it brings me data of a request (mother table) and the order items in xml(daughter table) currently the cursor brings request by request with fetch next, but the daughter table…
-
-1
votes1
answer55
viewsReturn zero when no record is found
I have a table that basically exist the Branch, the Revenue Code, the period of this revenue and the value of the revenue. I need that when generating the select it brings me information of the…
sqlasked 5 years, 2 months ago Rafael Leme 1 -
-1
votes1
answer44
viewstake field name in query and popular other!
I’m doing a search at the bank. On the table, I have 6 dates: data1, data2, data3, data4, data5 e data6. I’m sweeping these dates to find out which one matches the current month. This is already…
-
-1
votes1
answer57
viewsI need to change a table data with information from a different table
I have 2 tables I need that whenever a consultation is made or inves to show the tagname in Table 2 the data in the column mask and whenever a new tagname it already updates to mask Follows the…
-
-1
votes1
answer378
viewsERROR: Missing FROM-clause entry for table "new"?
Hello, I’m making the following mistake: ERROR: Missing FROM-clause entry for table "new" CONTEXT: Error occurred on dblink Connection named "unnamed": could not execute command. SQL statement…
-
-1
votes1
answer179
viewsFilter information from a CASE WHEN SQL and only results that contain all information
I need to return only the result that contains all the information that in the case of this image and the ID='8187' Select d.ID, d.post_title, d.post_type, MIN(CASE WHEN b.name = 'Resinas' THEN…
-
-1
votes1
answer43
viewsSession in php giving error
Good afternoon guys, trying since yesterday and not getting, next I have these two tables in the bank, when I soon save this session $_SESSION['username'] = $username; but they need to give a select…
-
-1
votes1
answer195
viewsGroup two columns into two mysql tables
I have two tables that I am joining to recover the related data in this way: Tabela Processos: Tabela Anexos id | processos processoid | titulo 1 | Processo 1 1 | REQUERIMENTO 2 | Processo 2 1 |…
-
-1
votes1
answer81
views -
-1
votes1
answer322
viewsInsert data into a foreign key database
I am doing a database course and we have made a database with several tables with Foreign key below. I would like to know how to enter the data correctly in this table, because when inserting the…
-
-1
votes1
answer88
viewsHow to get a Procedure return using ODBC in PHP?
I am trying to communicate PHP with the Caché database of Intersystems, but I will need to use ODBC to communicate. My doubt is how I can get PHP to return Procedure, in the case of a String, I’m…
-
-1
votes1
answer42
viewsSelect time in Mysql
Good afternoon guys! All right? I am developing a plugin that pulls from a database the television programs, it should pull by the time and show in a table the programs that are playing live,…
-
-1
votes1
answer111
viewsPHP with PDO returns full SQL date
I have a PHP application that reads data from tables that can be SQL or Postgres. When I started using PDO instead of mssql, the SQL data fields return ex: 'Nov 29 2019 12:00:00:AM'. If you query…
-
-1
votes2
answers492
viewsHow to check if there are only numbers in the CPF and CEP in SQL
I’m doing a database job and I need to check if the CPF and CEP have only numbers, since they are as varchar, does not need to be valid (for now), but if there are letters, not to be registered.…
-
-1
votes2
answers65
viewsSearch multiple tables at the same time Mysql
Well, I’ve got the tables professores, materias, turmas. To make it easier and simpler (because all I need is that data), say that there are the following data: turmas (2)…
-
-1
votes1
answer36
viewsHow can I run a Rigger that automatically updates a table when an attribute is updated?
Create OR Replace TRIGGER filme_log before Update OF custo On filme Referencing New As New Old As Old For Each Row Begin Insert into filme_log Values(:new.nome_original, :old.custo, :new.custo,…
-
-1
votes1
answer113
viewsSyntaxerror: Unexpected Identifier in /Users/apple/Documents/Nodejs/views/index.ejs while compiling ejs
I have a problem running my SQL. When I run on localhost, my code is normal. Follows code. const express = require('express'); const fileUpload = require('express-fileupload'); const bodyParser =…
-
-1
votes1
answer1044
viewsORA-01722: invalid number
Help me with this error please, I wanted to understand why it is happening when trying to recover the ID of the enrollment field, when selecting the enrollment field in my select list in my form.…
-
-1
votes1
answer98
viewsSearch for two columns in the database
I need help on how to do a two-column search, I’m a beginner. If I type a category it finds, if I type a city it finds, however, if I type category and city ex: agencies são paulo he returns…
-
-1
votes1
answer167
viewsHow to pick random values from a table in Bigquery (SQL)?
Hello. I have a table where I have in one column a registration number and in another the number of keys registered in this record. I am willing to take this data for analysis, however, as there are…
-
-1
votes1
answer383
viewsAccumulated balance with multiple accounts - SQL
I’m having trouble creating an account statement that has the option to filter all accounts and/or only a few accounts. I am using this SQL to appear these record this way select bancos.id,…
-
-1
votes1
answer36
viewsUnrealized/ subquery failing
Using Sub-Query, make a query that returns the active materials, with the Description, Batch, Barcode Cod and Validity only of Dt Smaller validity of each Material. My code so far: select…
-
-1
votes2
answers89
viewsCan you help me optimize this SQL query?
I am having a problem with this sql query. Its return time is on average 10 seconds and ta using 100% cpu. Probably because it uses many subquery. However I’m not able to optimize it. Does anyone…
-
-1
votes2
answers46
viewsQuery help for the problem created?
I need to create a list composed by the fields Current and Next Stage both stage names coming from the same table. Example of the result I seek: Stage Table (stage name provider) The query searches…
-
-1
votes2
answers67
viewsHow do I get records from my database in ascending order(of id), but I want it to take one by one
<?php $conn = mysqli_connect('localhost', 'root', ''); if($conn){ $Selectdb = mysqli_select_db($conn, 'quiz'); } $sql = "SELECT * FROM perguntas ORDER BY…
-
-1
votes1
answer39
viewsHow do I print data by data in sql?(selects all data, but only prints one by one in array format)!
$sql = "SELECT * FROM perguntas ORDER BY id_pergunta"; $execsql = mysqli_query($conn, $sql) or die("Erro"); while($row = mysqli_fetch_array($execsql)){ # code... …
-
-1
votes1
answer107
viewsINNER JOIN data mixed in php + json
Good evening, so I’m trying to create a API, and I came across the following problem, I’m not able to group the data from my inner join, follows the code : <?php $json = array(); $db =…
-
-1
votes2
answers159
viewsMake Join in table that has two ID in the same column
The scenario is as follows: I have my service order tables and my technicians scheduling tables for each service order. The problem is: In my OS table I have, for example, the protocols "123" and…
-
-1
votes1
answer125
viewsReturn records according to percentage in sql server
Good night, I need to make a select that returns only the records that were paid more than 60% of the installments. I created a table with the following structure: CREATE TABLE PARCELAS( IDPARCELAS…
-
-1
votes1
answer1081
viewsERROR "Object Reference not set to an instance of an Object error" Visual Studio 2019 - Script View
Hello, I am doing lesson 6 of the Analysis Services tutorial and when trying to make the View Script the error arises: "Object Reference not set to an instance of an Object error". I just get this…
-
-1
votes1
answer60
viewsHow to read data from a postgresql SQL?
Hello, Good afternoon I am relatively new programming, I have been working on a project that involves the mapping of some equipment, I did my part without problems but now I need to insert data from…
-
-1
votes2
answers325
viewsAdd records from a field and display in PHP (values have R$ in front)
Hello, I’m trying to sum up some values using the SUM and is returning 0. The fields I will use: category month value (want to add this) I want to add the valor of all records of each category and…
-
-1
votes2
answers31
viewsCode problem probably coming from Sqlserver
I’m trying to create a very simple login system, I’m new to programming and I’m still learning and I came across a mistake, The compiler does not present any errors however when running and trying…
-
-1
votes1
answer57
viewsBring data regardless of the order of the numbers are found
Good afternoon! Can someone help me? I need to bring the data of a query (query) with the return as below, regardless of the order of the numbers are. I have a table of metrics, and this query is…
-
-1
votes1
answer47
viewsSelect in php recognizes only one variable
I need to search the database for dates and compare them to the dates generated by a for. If they’re the same, they turn red. I already got the numbers for one Select and store them in one array…
-
-1
votes1
answer29
viewsAzure connection - SQL Server 2005
I’ve been trying to connect on the Microsoft Azure database server to an application encoded in . Net Framework that is running on a windows server 2003. The problem is that only this server is…
-
-1
votes1
answer66
viewsHow to pass multiple lists in a query? Using JPQL
The problem is this: I have a controller that receives a list of Integers: [1245,12346 ...] In my table I need to consult using this list but the columns are separate, IE, the first digits are in…
-
-1
votes1
answer119
viewsHow to get the table name of the first select Oracle?
I have the following oracle query: SELECT * FROM TABELA_PESSOA A WHERE A.CPF IN (SELECT B.CPF FROM TABELA_CONTA B WHERE B.CPF = A.CPF) I want to get the table name of the first select which is the:…
-
-1
votes1
answer31
viewsHow to put more than one Get method along with the sql code to send the information in the bd ? Example: Put email and password
Php user. #Conexao/categoria.php include_once 'conexao.php'; class UsuarioDAO{ public function Inserir(Usuario $usu){ try{ if (!empty($usu->getNome())){ $sql = "INSERT INTO usuario (nome) VALUES…
-
-1
votes1
answer46
viewsSQL-TRIGGER MAKING AUTO NUMBERING WRONG
Hello, I’m studying sql for very little time so I’m sorry if any nomenclature is not ok. I’ve created some triggers for my test database and in some cases it’s working perfectly. In others however…
-
-1
votes1
answer28
viewsProblem with SQL return
I have a table that connects two other tables. "Request" it links "Customers" and "Solitation_description" It has the cliente_id link columns and request_descricao_id, I need to return clients who…
-
-1
votes1
answer143
viewsPHP Notice Code Error: Undefined variable: Connection in C: xampp htdocs admin Register.php on line 283
The following errors appear when opening the table page: Notice: Undefined variable: Connection in C: xampp htdocs admin Register.php on line 283 Warning: mysqli_query() expects Parameter 1 to be…
-
-1
votes1
answer188
viewsHow to not add zeroed values - SQL
I have several columns and some of them are practically zeroed, like every 100 rows have a value. I’m adding these columns with SUM(column1), SUM(column2)... but when adding up these columns I don’t…
-
-1
votes1
answer166
viewsAdd days to a date in mysql and compare it to the current date?
I have some conditions on a page of my system, I need to put something in my SELECT so that on his own SELECT has already entered a certain condition. The condition is as follows, I need these two…
-
-1
votes1
answer352
viewsError in sqlite and javascipt
I was making a video lesson and followed the exact same steps of the teacher, but this giving the following error when I execute the code in the powershell Even before you start entering the sqlite…