Newest sql Questions

Q&A for professional and enthusiast programmers

Impala: duplicate table alias when trying joining on multiple columns

I want to left outer join table A and table B on multiple columns. Below is my code: select * from table_A left outer join table_B on (table_A.a1 = table_B.b1) left outer join table_B ...

Tips for creating a website where users can create quizzes for others to use

For my a level project I am creating a website where users can login and create quizzes, which will be uploaded to a database and other users can access the quiz and take it. Does anyone have anything ...

sql server RESTFULL API for AJAX

Does anyone know how to build a RESTFUL API to usewith existing sql server database? I'm using AJAX/Javascript/Jquery/Apache Cordova. Thank you!

sql query to get info from the same table?

lets say I have a table structure in the following format: ParentItemId is an id to the Item table itself. Item, ItemId, ParentItemId --------------------------- Apple 1 0 Orange 2 ...

browser takes too much time for fetching the data [on hold]

I have a web page which fetch the data from DB and display it in jsp...My DB consists of more than 3000 values..All the data..should be display in jsp...Whenever I click that jsp ,it takes more than 7 ...

Rename auto-generated virtual key field

SQL database, in mvc project I use EF to create model classes. One of the classes has two fields related to one field of another class, many-to-one relation. They are named like "Field" and "Field1" ...

How do I fix this Parse error in this SQL query?

I'm getting a parse error when I run this SQL query, what am I doing wrong? $num_of_model_updates_sql = "SELECT model_id FROM updates_models WHERE model_id .= $models[$row['model_id']]";

Query Count Google Sheet

Per category (example engineering) I need to perform 4 queries where the output of each query matches a number of persons. 3 of my queries worked ( for columns R - S - T), meaning the output is ...

Access queries, autoincrement

I’ve recently trying to use Access/SQL in work. It’s going somewhat ok but I’ve still a few questions. I’ve created a few small queries, the first two of which are working. This first one just ...

Show only columns with values as result of a dynamic sql-query

I have an html form to read out data from an sql-database. According to the selected criteria, the results are shown in a dynamically generated table. This works well with the following code. The ...

How to store a long string in a varchar(MAX) column by c# code?

All related subjects i saw in this site discuse stored procedures and alike. I have a C# program that receives a string (not important from where, maybe file or uploaded) and tries to insert it in a ...

postgresql expression wher id is in array

I have an array of ids such as: a = [13, 51, 99, 143, 225, 235, 873] What is the most efficient way of getting the records where the id is in the array. I don't really want to use or such as ...

creating new columns with frequency of the category in sas sql or r

We've been working on really big dataset which has almost 28000000 observations. structure of the dataset is like above, and column "S" contains almost 4800 levels of nominal values. Those are coded ...

Recursive parentIDs

I have a table that include department data and it has the following structure, +----------+--------+----------+ | deptName | deptID | deptHier | +----------+--------+----------+ | a | ...

What is the difference between how objects are handled in Dapper and Entity Framework - with raw SQL queries?

From my reading, Dapper is suppose to be more SQL friendly, but Entity Framework (EF) allows raw SQL. I typically use SQL, but I like some of the things in EF. Many of my queries are fairly complex, ...

sql converting time in hh:mm am/pm format

I want to display my results with a hh:mm am/pm format however my query below is only working for the am results but not time from 12:00pm and on select timein, timeout, SUBSTRING( convert(varchar, ...

SQL conditional logic on one field not affecting the grouping

I have the following data: ID ActionType Quantity Fee 1 Commission 1 10 1 Open 2 10 2 Commission 1 20 2 Close 3 20 3 Commission 1 ...

MSSQL ODBC refusing valid TINYINT values (Numeric value out of range)

I'm trying to insert into a TINYINT column which according to MSDN docs should take numbers between 0-255. Unfortunately it only takes 0-127. If I try to insert 128 or higher it complains: [22003] (...

SQL Server express is not installed on your system

when i try to open code for an existing mvc application in Visual studio 2015, it is giving warning like, 'SQL Server express is not installed on your system.' In that application, have connection ...

SQL real estate agend column

I am making a real estate agency database. The tables that are currently included in the question are a table for the employees, purchases and the real estates. I want to put a ServedByEmployee column ...

Reusing SqlConnection in multiple ninject bindings

TLDR: How do I re-using or instantiate a new Sql Connection object in my Ninject bindings? ****The second binding is failing**** due to SqlConnection is not initialized. I assume I can't share sql ...

Delete Customer data in SQL that have not ordered since certain date

Say I have two tables. A customers table and a orders table. The customers table has a list of anyone that has ever placed an order, while the orders table has a list of every order ever made. These ...

SQL Update to Linked Server Table fires trigger for each row effected

I'm looking at some strange behaviour with a linked database server. I'm simply creating a temporary table variable, adding in some keys which can be found in the linked server table and using it to ...

Sequential SQL query

A newby to SQL question so please forgive me Any clues of a simple SQL query? I am trying to sort a series a results where there is a break in a range of numbers. eg R00000D to R99999D. ...

Export Images from Database to local folder

I have two columns in a table: ID, Image (Bytes) I need to storage all the images in a local folder using the ID as a Image name. How can I do that?. I musing SSMS 2008 R2.

Populate Oracle table with test data for PL/SQL generator

I would like to write PL/SQL generator of dummy data (e.g. names as combination of first and last most popular names) for Oracle 12c. So I need to populate names and surnames tables with source data ...

MySql: Where for each id

I have a table of prices defined like this: Prices amount item_id effective_date end_date item_id is not unique, so I have a list of items and I want to get their corresponding amount according to ...

OVER() function in R using sqldf without RPostgreSQL?

I'm dealing with some sensitive data, so I'm concerned about using RPostgreSQL. I have all the data necessary loaded into dataframes in R. I'm trying to run queries on the data using the sqldf() ...

SQL exception no such column if clause

The problem with the following code is in if statement. Although I use `rs.getInt("CLIENTID") == clientId throughout the code, java.sql.SQLException: no such column: 'CLIENTID' There clearly is ...

SQLite - Querying DB once to produced desired table rather than multiple times

I'm developing a small little side project for work, and the final query I need to write is naturally the most complicated. I'm an SQL newbie, so any help would be greatly appreciated. The relevant ...

How can I remove duplicates from my file, while certain fields take priority?

So I have SQL that will add a code to a field if it detects duplicates. There is another field called DS DS can either be 'yes' or it can be 'no' How can I make it so if it finds a duplicate, 'yes' ...

How to create comma delimited list from table with dynamic columns

I want to be able to grab all of the records in a table into a comma delimited list that I can then use to insert into a table on another database. Due to permission restrictions on the customer's ...

DBMS: Insert query consistency for constraints PK, FK

Lets suppose that we have a database with three tables: R(A',B,C): 100.000 records, r=100 bytes/record, bfr(R)=40 records/block, B(R)=2.500 blocks S(B',D,E): 1.000 records, r=200 bytes/record, bfr(S)...

How to check if field value is same as combobox value?

So I am making a SQL query in which value of combobox (cboVU) shoud be same as field in table called Vrsta uredaja in table O klima uredaju. I am making this query in Access 2016. I am getting this ...

Are JDBI @bind and bind method free from SQL Injection?

I have tested @bind annotation with some SQL Injection attempts and seems like the input is sanitized. For bind method, I am not sure whether it's also true. Can someone confirm whether my guess is ...

Remove records by clustered or non-clustered index

I have a table (lets say ErrorLog) CREATE TABLE [dbo].[ErrorLog]( [Id] [int] IDENTITY(1,1) NOT NULL, [Created] [datetime] NOT NULL, [Message] [varchar](max) NOT NULL, CONSTRAINT [...

Prevent `resultSet.getString(index)` from skipping over null [Java]

A method takes String query, String[] names, DataType[] dataType to pull data from SQL db and convert the ResultSet to a table-like structure. It returns a List of Maps. Each row is a map "column ...

SQL Unexpected SELECT

I'm dynamically constructing a query within C# based on passed in parameters. It's constructing the query correctly based off what I'm passing in yet I cannot figure out why the query keeps throwing ...

Correct way to join on 3 Tables

I am trying to pull data from 3 different tables and my result set is not what I'm expecting. SELECT mdp.ReportDate, mdp.PolicyNumber, Company, StateCode, LOB, mdp....

Rails 4 query records where nested has_many is empty

Working in Rails 4. CompensationRecipient --has_many--> Compensations --has_many--> Payment So: class CompensationRecipient has_many :compensations end class Compensation has_many :payments ...

SQL price column confusion

I am currently making a real estate agency database. With a few words... the database has a table for the purchases and for the real estates... (it actually has more but I think they are not necessary ...

Visual Studio Web Application using C# to send data to a SQL database issues (cmd.ExecuteNonQuery();)

I'm having an issue with my code revolving around cmd.ExecuteNonQuery(); and the error: Must declare the scalar variable "@drID1". The first time i click the button this code is linked too it runs ...

Join multiple select statements using Querydsl SQL building

I am trying to build an SQL query using Querydsl that involves joining multiple select statements together. A simplified example of the SQL would look like: select sensor1_dt, sensor1_avg, ...

How to divide the input of a variable when reach it's maximum length

I am writing a procedure which takes the body of other procedures and store them localy in my device as a text file It works fine but i notice that if am having a large procedure it will be cut off ...

Default ID in SQL xml

I am using the sp_xml_preparedocument feature of SQL to convert an XML string into a temp table like so: create table #ExportTemplate ( ExportTemplateId uniqueidentifier not null default ...

Running Powershell via SQL Server Job

I have a very basic script which runs fine on my local PC. It simply backs up some folders and their contents then adds a date stamp on the folder name. The script backs up folders on two different ...

SQL: If there is No match on condition (row in table) return a default value and Rows which match from different tables

I have three tables :Clinic,Stock and StockLog. I need to get all rows where Stock.stock < 5 . I need to also show if an order has been placed and what amount it is ;which is found in the table ...

Limit Query Result Using Count

I need to limit the results of my query so that it only pulls results where the total number of lines on the ID is less than 4, and am unsure how to do this without losing the select statement columns....

SQL: For each column1 find it's row with max value of column2

I have a table that looks like this: I want to get for EACH id the row that has the biggest value in feedbacks. So my expected results should look like this: I've tried to do this: SELECT id, ...

sql 2012 convert image to nvarchar(max) returning null in Crystal and not working in gupta report builder when the text is longer than 250 characters

So I have a database that was upgraded from 2008 to 2012 for our main ERP application. Many columns within the database have been "upgraded" to support unicode tho the default collation remains the ...
Translating... 0%