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
answer151
viewsSQL in Genexus and Gxflow
You can return the result of an SQL query in Genexus transaction? I need to create a Workflow through Genexus, where using DBRET, I was able to read the data from an external BD and now I need to…
-
0
votes1
answer611
viewsSelect from two tables and insert into two other at the same time
I have four tables tabela A aic002 campos : codigo data nome especie valor rg cpf exped Tabela B excli campos codigo nome rg cpf exped tabela C imovel Campos codigo imovel rua bairro cidade estado…
-
0
votes1
answer7900
viewsQuery using between with sql server 2005
I’m making a query using the operator Between to select a date range, in the SQL Server 2005 database. Below are the table data Servico: linha1: 2015-02-04 14:51:01.577 linha2: 2015-02-04…
-
0
votes0
answers157
viewsHow to use INSERT INTO (Currency Value) + SELECT (String Value) SQL DB Access
I’m trying to insert some data into a format column Currency, but the data is String. I tried to make the conversion using the Convert(Dados_String, Currency), but it didn’t work either. Follow the…
-
0
votes2
answers503
viewsUse ON CASCADE DELETE in SQL
I have two tables in SQL, a call Patient and another Diagnosis, I can do all the operations with the diagnosis (insert, edit and delete), but I just wish it was possible to delete diagnoses that…
sqlasked 9 years, 9 months ago Mario Medeiros 173 -
0
votes0
answers54
viewsQuery from selection in comboboxes
I have four comboboxes populated with data from a database, using js. The user selects options in these 4 boxes and, from there, I want to do a query with the options chosen. How can I take these…
-
0
votes2
answers1574
viewsHow to get date and time in different columns through a select Sql server?
I have a problem need to filter a query under the following conditions : I have the Data field and I have the time field both in varchar , when I try to make the query like this: ex: select Serial,…
-
0
votes1
answer72
viewsConcatenation Create Table
I’m trying to create a table from the user’s email, and I’m using the code below: $email = $_SESSION["email"]; echo $email; $create=mysql_query("CREATE TABLE userpics_'$email' (id_user VARCHAR(60),…
-
0
votes1
answer788
viewsHow to sum the values of a specific column with the sum() function?
I have the following command: select substr(b.chave, 28, 7) numeronf, upper(d.apelido) usuario, decode(b.loja,1,'Loja 1', 2,'CD', 3, 'Loja 2', 5,'Loja 3', 89, 'PANIF', 90, 'Restaurante' ) loja,…
sqlasked 9 years, 9 months ago user20360 -
0
votes1
answer485
viewsPostgresql Constraint error
I have a code that is giving the following error: there is no Unique Constraint matching Given Keys for referenced table "schedule" Code: CREATE TYPE weekday AS ENUM ('Domingo', 'Segunda', 'Terça',…
-
0
votes0
answers59
viewsQuery return does not match
I’m trying to create a query that returns the calculated cost of certain products, and I’m curious to know why when we do joins - in case a left join - the result that should be x becomes w. The…
-
0
votes2
answers695
viewsSQL does not return all results that should return
I have the following tables in my bank: and wish to select all products of a particular site (this site is marked by the user through a checkbox) with the following sql: SELECT Eletrodomestico FROM…
-
0
votes0
answers321
viewsDivision of duplicates into a Subreport - MSSQL/Crystal Reports
I would like to generate a tax forecasting report for PIS and COFINS, which are calculated based on a CFOP code of banknotes issued in a given period, but I would like to separate this information…
-
0
votes1
answer125
viewsdelete record from an sql table
Good people I want to delete a record from a table but for that I need to get information from other tables and because of that I am not able to delete. I basically needed an SQL command that…
-
0
votes0
answers90
viewsReturning an empty table
create function teste( teste varchar ) returns setof record AS $$ begin execute teste; return ; end; $$ language plpgsql; select teste ('select * from public.opcional '); This returning me record…
-
0
votes1
answer143
viewsChange part of all two-column records through a reference
Good evening, everyone! I am Noob in SQL and I intend to strive to learn more with your help. Details: Columns belong to the same table The part of the record to be removed is common in all Rows,…
-
0
votes2
answers882
viewsSubselect in the same column
I am trying to create a subselect in the same column, I have to use a column row to return a new value from the column itself.. follows my sql code SELECT `idUnidadeOrganica`, `NmUnidadeOrganica`,…
-
0
votes0
answers73
viewsReturn columns according to sql server criteria?
How could I return the column names of a table according to search criteria? I want to return the columns that are with option’S', all fields is a char of 1 that takes "s" or "n" select b.livros,…
-
0
votes3
answers278
viewsSQL query in wp_postmeta table
How to make an SQL query in a table that has the following fields: SELECT meta_key,meta_value from wp_postmeta where meta_key = 'cidade' and meta_key = 'bairro' the fields of the table wp_postmeta…
-
0
votes1
answer110
viewsUpdate database by SQL PHP
Staff I am having difficulty updating my database to decrease the weight by 1 kg. Any help I appreciate. The code is as follows: <?php class Aluno{ public $nome; public $endereco; public $peso;…
-
0
votes1
answer234
viewsCreate SQL timer column
Is it possible to do a timer column, which calculates 24 hours? For example, PHP starts this timer in this column, and until it resets the user is prevented from performing such an action. However,…
-
0
votes1
answer1761
viewsError: There are no Primary or candidate Keys in the referenced table
I am trying to create a new table in an existing DB, however, appears the following message: There are no Primary or candidate Keys in the referenced table 'parceria_conta_corrente_ao' that match…
-
0
votes3
answers1148
viewsTake a variable value from Sql Server
I have this Sql block: SET NOCOUNT ON; Declare @QueryString as NVarchar(4000), @Datazero as varchar(20), @Datamn as varchar(20), @CdUsuario as integer, @SitProcesso as int ,@DsUsuarioRede…
-
0
votes0
answers450
viewsProblem creating Foreign key in mysql
Well I have to relate 3 tables and I’m trying to create the foreign key I can create only that in php I have a INSERT for one of the tables that does not perform the insertion and accuses the…
-
0
votes1
answer5001
viewsRemote procedure call failed. [0x800706be]
After installing SQL Server 2008 R2, access SQL Server Management Studio but server name does not appear and SQL Server Configuration Manager services are not active.…
-
0
votes1
answer77
viewsDoubt about 'NUMA' (non Uniform memory access) in Microsoft SQL Server
Someone can help me understand in English the concept of 'NUMA' and its characteristics? I have found sites in English etc, but I still do not understand!
-
0
votes1
answer452
viewsSearch records from one date to another
The company has the base closure of "21 to 20" each month. Would you like to know how I make SQL only search for the records that are inside the lock? Ex: my closing this month is: 21/05 to 20/06,…
-
0
votes1
answer473
viewsTrigger that feeds a table with information from another Mysql
I have a database in Mysql with Stock, Sales and Ite_sales tables. When making a sale record information in the Sales and Ite_sales tables, but I want to get information from the Stock table and…
-
0
votes1
answer48
viewsSelect by deleting another Select
well my scenario is this, I have 1 slide where shows the 4 last news SELECT * FROM noticias WHERE destacar='Destacado' ORDER BY idnoticia DESC LIMIT 4 below the slide I have a list of the other…
-
0
votes1
answer850
viewsRun a query by clicking on the result of another query
I have the following column structure from my database: account_id, name and appearance. Imagery: http://puu.sh/gYLVL/4083073484.png I had the following code previously: <font size="3">Por…
-
0
votes1
answer92
viewsJoin Arrays with php
good guys to making a system and need to return session and database values most wanted it within a single array, using the function array_unshift() he returns me the following Array ( [0] =>…
-
0
votes4
answers79
viewsError in SQL like
I’m trying to make a select where I want all the data of a person who has the same ip and date equal to today’s date. The reason is that I need to restrict as many times as a person sends contact to…
-
0
votes1
answer2617
viewsHow to use the current date in a trial?
Good night, you guys. I need some help. For you to understand, I am trying to execute a system process that asks me some variables that I can pass them in a fixed way, but one is date. in case the…
-
0
votes1
answer349
viewsSave user message to text file or database?
I am developing a PHP system following the MVC(Model-View-Controller) standard. I decided to create an account deletion page for users and display a text field so that they can inform us why they…
-
0
votes1
answer915
viewsShow products by category parameter in a more optimized way
Good evening! Well, I’ll explain what I’m trying to do. I have a table in my database that corresponds to the products and I have a page that shows these products. It happens that one of the…
-
0
votes2
answers386
viewsLINQ to Entities does not recognize the 'Boolean Like' method?
I am having this error when trying to make one with query using LINQ to SQL after making the suggested changes: {SELECT `Extent1`.`idcliente`, `Extent1`.`nome`, `Extent1`.`pai`, `Extent1`.`mae`,…
-
0
votes1
answer379
viewsHelp - Collation Conflict
Srs(as), good afternoon, Could help me identify a problem? I am changing a PROC and when testing it is occurring the following error: Cannot resolve the collation Conflict between…
-
0
votes3
answers1649
viewsInserting column in Oracle table with conditional
I need to create a column in an existing table but need to do with a checking condition if this column already exists in the bank I did so but it throws an error: DECLARE col_count integer; BEGIN…
-
0
votes1
answer42
viewsStructuring in the bank the paths to the images and videos of my product?
How can I structure in the database the paths to the images and videos of my product? Below the SQL of product table creation: CREATE TABLE products ( id INT AUTO_INCREMENT PRIMARY KEY, name…
-
0
votes3
answers864
viewsMake primary key uplinkable
When entering the data in my SQL table everything happens normal. However, when trying to insert for the second time, with the same value in id which is the main field of the table, it returns the…
-
0
votes2
answers326
viewsPHP + SQL UPDATE PROBLEM
Good morning, you guys. I am making a simple quiz for my web class and I have a problem to update SQL via PHP. The database is set right, select works but the update is inert in the system. No error…
-
0
votes1
answer1293
viewsHow to apply multiple image upload
Hello I have this code that generates in the case of multiple adders with everything I’m not sure how to make an image upload code to upload all the images that are placed in FILE of the field of…
-
0
votes2
answers89
viewslinks between tables
$sql = "SELECT * FROM Inscricao WHERE al_id = ".$_GET['idc']; $sql = "SELECT * FROM Aluno WHERE al_id = ".$_GET['idc']; $sql = "SELECT * FROM EncarregadoDeEducacao WHERE ee_id = ee_id.inscricao…
-
0
votes1
answer349
viewsUse comboboxes to list cities and neighborhoods
I want users to select the city and neighborhood where they are and then the city and neighborhood where they want to go through 4 comboboxes. The data is being pulled from the database, and the two…
-
0
votes1
answer5886
viewsHow to delete records from multiple tables at the same time?
I want to give delete in a student for that I want to delete the records of that same student of all the tables where he is and his image of the folder where it is was saved for that I use the…
-
0
votes1
answer47
viewsVariable in SQL query
Guys, I’m trying to make a query with a variable that I’m receiving, but it’s not working. Any suggestions ? $model = $_REQUEST['model']; $customer = $_REQUEST['customer']; SELECT * FROM sistema…
-
0
votes1
answer389
viewsDelete only one record in the database
While executing the code below, more than one record is deleted from the database. I cannot find the problem. Code to delete excluir_client.php <?php require 'repositorio_clientes.php'; $clientes…
-
0
votes2
answers215
viewsIgnore dot in a Query
I am trying to run the following Query: select codigo from cliente where codigo ilike '%99.999.999%'; I thought by putting the ilike, he would ignore everything, points and accents but I was wrong.…
-
0
votes1
answer435
viewsCount SQL query with PHP percentage
I’m making a report and I need to count and display the number plus the percentage for the total count. With this code I already count. It is possible to display the percentage beside using sql and…
-
0
votes1
answer9931
viewsSelect like (2 different parameters)
I have a table with several cars, I need to get only the ones I need. Example: goal fox Parati Kombi Voyage I want to catch only goal and Kombi. I am using the following command to pick up where GOL…