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
answer40
viewsIgnore a certain value with AVG
I wish I could calculate it AVG ignore the values above 100000 (10 seconds), with the following query: user_id, COUNT(*) as total, AVG(`exec_time`) as tempoMedio, SUM(CASE WHEN `success` = 1 THEN 1…
-
0
votes1
answer988
viewsError: There are no Primary or candidate Keys in the referenced table
I’m trying to relate these two tables IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'Periodo') AND type in (N'U')) DROP TABLE Periodo GO CREATE TABLE Periodo( Numero tinyint NOT…
-
0
votes0
answers36
viewsError adding Stored Procedure to map in Crystal Reports
When adding an SP with data type parameters date, adding the following error information is displayed. Variables in the AS ALTER PROCEDURE [dbo].[spExtractoTSL] ,@DataInicial DATETIME = 0…
-
0
votes2
answers1214
viewsRepeated values when making an INNER JOIN
This code below is bringing repeated values on the screen. Could someone help me ? $id_credenciado = $_SESSION['id_credenciado']; //$sql = mysqli_query($conn, "SELECT DISTINCT * FROM tb_protocolo…
-
0
votes1
answer146
viewsI can create a table in mysql that shows the person’s age by subtracting today’s year - her birth year?
Question: I can create a table in mysql that shows the person’s age by subtracting today’s year minus her birth year? create table idade2 (ID auto_increment Primary key, data_nasc date, idade int as…
-
0
votes1
answer401
viewsCreate Slug across MYSQL database
I have an older MYSQL database and in it I have a news table and I needed to create a "Slug" column to save Slug from the news. Therefore, I would like to create an automatic Slug for all records…
-
0
votes1
answer8478
viewsSelect most recent record from a given table - Postgresql
I need to select the most recent record of my Estoque case the column data be different, I managed as follows to bring the oldest when the dates are different: SELECT codigosuprimento, numeroserie,…
-
0
votes0
answers21
viewsPaging in SQL
I have a SELECT that needs to turn into a PROC with paging to be consumed by an ASP (classic) page. Could you help me? Below is the SELECT: SELECT A.NOMUSU, A.NOMMAE, C.ATIVID, B.DSCEND, B.NUMEND,…
-
0
votes1
answer28
viewsError in Wordpress on the Admin panel
Personal developed a site with Wordpress that can be seen from this link but when accessing the wp-admin appears this error what can be: OBS: I installed a plugin quiz was stirring normally and out…
-
0
votes2
answers259
viewsSingle auto increment on all DB tables
Hello, my DB has several tables that have the same column: `PROD` int(11) NOT NULL AUTO_INCREMENT This column is an identifier that makes one that makes an increment with each launch. The issue is…
-
0
votes1
answer362
viewsFind text in sequence in a string
I have this String in oracle: 'Order linked with Sale : 4575987/10' and I would like to return only the order number in this case the 4575987/10. Until now the maximum I could is passing a fixed…
-
0
votes1
answer47
viewsSQL Nestled doubt
I’m using that SELECT, but now I need to search the fields in the client table (ex: cli_clifone and cli_clicontato) , how can I include to bring this information into the SELECT below, I’m trying…
-
0
votes1
answer96
viewsSql. table, organized date and time
I have an sql table that will contain appointment, date and time. I keep the three based on ID. I have a question about the date and time id = 0; data 28/08/2018 - 13:11h id = 1; data 26/08/2018 -…
-
0
votes1
answer44
viewsSelect database data within another while?
I have a calendar made by me, not very good, but made by me, in which has a while creating squares, ie the days, of the current month. So far so good, but now I would like, if a certain day had an…
-
0
votes0
answers594
viewsHow to change Mysql to Mysqli
Well, half of my project is using mysql plus I added a new function that uses mysqli which is generating some conflicts in the database. Either it saves what is in mysql or what is in mysqli. I…
-
0
votes2
answers250
viewsOrder By in 2 MYSQL tables
Good morning! I am going through more moments and I would like your help with this problem! Come on, I’m doing a select in MYSQL where several tables are selected, in opencart to generate an XML for…
-
0
votes1
answer98
viewsMake Join with table columns where id equals variable
I have 4 tables they are already with Foreign key. aluno: id matricula username curso_id // referencia a id_cursos da tabela cursos, coluna id_cursos. cursos: id_cursos nome_cursos modulos:…
-
0
votes1
answer56
viewsHow to make Join with multiple tables?
I have 4 tables they are already with Foreign key. aluno: id matricula username curso_id // referencia a id_cursos da tabela cursos, coluna id_cursos. cursos: id_cursos nome_cursos modulos:…
-
0
votes1
answer123
viewsLIKE with COUNT in PHP
I can’t understand what’s going wrong with the code: $query="SELECT aluno FROM bonesmirn2 WHERE data LIKE '%2018-09%' AS faltas GROUP BY aluno HAVING COUNT(aluno) > 0 ORDER BY COUNT(aluno) DESC";…
-
0
votes0
answers26
viewsSQL SP sp_send_dbmail
I changed the SP [msdb].[dbo].[sp_send_dbmail] putting new parameter in it. Is there a time when this SP is updated and the changes made are lost? (SQL Server 2017) Thank you…
sqlasked 6 years, 2 months ago mwamoreira 1 -
0
votes2
answers453
viewsTrigger with null value
Good evening guys, I need you to check if the address and phone columns are null, if you are returning an error message, otherwise effective operation. my code is like this: CREATE TRIGGER VERIFICA…
-
0
votes1
answer230
viewsC# Join 3 tables using Linq?
I’m picking it up to learn C# and I’m picking it up at some points. I have 3 tables. Follow the models public class Tag { [Key] public int ID_Tag { get; set; } [Required(ErrorMessage = "Preencha o…
-
0
votes2
answers60
viewsData search without formatting sqlserver with select
I have a field on the table Clientes by name CPFCNPJ but your data is formatted with dots and hyphens and would like to make a SELECT formatting this data without punctuation. It is possible to…
-
0
votes0
answers67
viewsPostgresql compare time between two hours, and if it exceeds the hours of the day, limit up to 23:59
I’m making a query sql in the ruby-on-rails for PostgreSQL where I check if the user input is between hora_entrada and hora_entrada + (hora_entrada + limite_banco_horas) and the same goes for…
-
0
votes1
answer319
viewsHow to make a query bringing me the last value of a specific id
I’m trying to do a c# query with Mysql, where there are two tables: Compra --> Table where you take the IdProduto and the Product Value. Abastecimento --> Table where the IdProduto and the…
-
0
votes3
answers2563
viewsConnection to sql database on multiple php pages
I am creating a site where several pages need connection to the database to perform their operations, for example, I made a login system, so the user clicks 'login' opens a modal in bootstrap to…
-
0
votes0
answers299
viewsLogin to bootstrap modal
I created a login button in the site navbar, when the user clicks opens a modal with the login form. In the navbar php file I am calling the file "validaLogin.php" to check the user data and store…
-
0
votes0
answers51
viewsColumns of sql server tables are not recognized in php
I have columns that were saved in sql server with uppercase letter, when I receive in php I needed him to recognize them both minuscules and uppercase. For example: select * from rzv_aluno records:…
-
0
votes1
answer68
viewsProblems with using Ajax request
When I try to make a request to return an sql query to the form fields it returns only the first row of the table, how can I change my code to fetch all rows: select code: <?php class Medico {…
-
0
votes1
answer617
viewsError converting varchar field to float
I am generating a Query and in this Query I am making a Join between a field varchar and a field float. Being the field SY.YE_MOEDA is varchar and the countryside DA1_A1_MOEDA is float. Follow my…
sqlasked 7 years ago Junior Guerreiro 617 -
0
votes2
answers59
viewsProblem running SQL
Good afternoon. I have a simple SQL query Select * from Tabela Order By Campo Where this field is string, and this string has data like "xyz001", "xyz002", "xyz0011", thus, the "xyz0011" is…
sqlasked 6 years, 2 months ago gabrielfalieri 1,231 -
0
votes2
answers392
viewsError in Trigger - Mysql
I created the following Rigger, but it has a syntax error that I can’t find. The error is as follows ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that Corresponds to…
-
0
votes1
answer26
viewsSave information about execution days
Good afternoon, you guys. I have an automation monitoring system that consumes a table that contains information about n automations registered, about 40 currently. I would however like to do a…
-
0
votes0
answers106
viewsRun order of searched CASE expression
The CASE WHEN has two forms of functionally, with simple and researched expressions: The expression SIMPLE CASE compares an expression with a set of simple expressions to determine the result. The…
-
0
votes1
answer253
viewsInner Join without duplicating lines, bring the first value found
I have the following table with the fields below SELECT NR_ANO_MES, nr_contract, type_product, NM_PRODUTO, sum(QT) the QT FROM INN.FT_VENDA The product type field has 3 classifications (Video, data,…
-
0
votes1
answer45
viewsRemove Group_concat and list each one separately
I want to remove group_concat to list each one separately, some hint? SELECT U.login, (SELECT Group_concat(AC.curso ORDER BY id ASC) FROM alunos_cursos AC LEFT JOIN cursos C ON AC.curso = C.id WHERE…
-
0
votes1
answer962
viewsView with two or more tables with no link, with different columns and that need to be merged
I have two tables, "PRIMEIRATABLE" with the fields name, surname, and age, another table "SEGUNDATABLE" with the fields name, last_name, and acts the two tables have no link but need to join in a…
-
0
votes0
answers22
viewsFormatting date to save
Hello, I need to convert a date that is in String to save to a variable data_inicio of the kind Date in Mysql and I did it as follows: String data = "14/11/2017"; SimpleDateFormat formataData = new…
-
0
votes1
answer730
viewsPass object by Ajax
I would like to know how to get through an ajax request, bring to my site a list of elements, where these elements are lines of an sql query. For example, I have an employee chart. In the form, when…
-
0
votes1
answer59
views -
0
votes1
answer842
viewsMysql - How to make a Stored Process be activated once a day?
I need a Stored Procedure to be called every day at 11:59 pm but I’ve tried a few ways and when it arrives at that time it doesn’t perform! CREATE EVENT `ATUALIZARDADOS` ON SCHEDULE EVERY 1 DAY…
-
0
votes1
answer96
viewsCreate Mongodb database and user via shell
I need to create database and Mongodb user, but all via shell. I found something about --Eval and --shell, but I couldn’t make it work, I’m trying it that way: mongo mongodb://11.11.123.321:27017…
-
0
votes1
answer136
viewsINSERT with Random SELECT
I have a table with several information and another empty. I need to do an INSERT in this empty table with only one information from the other table, but SELECT has to be random. I am using the…
-
0
votes1
answer73
viewsList 2 Tables in One Oriented Object
I’m doing some academic work. and I’m not listing the BD data, that is giving the error java.lang.Nullpointerexception I searched something similar found , I saw some examples however the way they…
-
0
votes1
answer84
viewsSQL command to add up the vacancies occupied on a specific day of a parking lot
Talk guys, I’m having a little trouble finishing a college job and it would be really helpful if you guys would help me with a little VIEW. Here are the fields of the parking table: CREATE TABLE…
-
0
votes0
answers45
viewsGreek theta symbol inserting into SQL
We have an application here at work where we generate some screens in Portuguese and store in a database to have an easy flow of deployment in a productive environment. But when adding the screen to…
-
0
votes0
answers55
viewsDoubt with Image fields in Postgres
I used the sql below to view the size of all tables of the database, it return me a total of 98 MB, more as the database has images that are recorded as binary and the same are not in a table, I…
-
0
votes1
answer711
viewsCheck the frequency of records in the table
I have a table where are saved all services performed in several cars. The key is the car plate. A car can have more than one service performed per day. And for each service performed a new service…
-
0
votes1
answer568
viewsConvert entire mysql database to lowercase
It is possible convert all columns of tables in a database mysql for lower-case letters? I have several records and several tables, all are a patchwork of upper and lower case (and some with…
-
0
votes1
answer152
viewsSQL rule to filter only one month in TIMESTAMP field
Hello. I have a stock drive in month 1, month 2, month 3, month 4, month 5... how do I create rule for appearing only stock drives in month 3? Remembering that the field is TIMESTAMP.