Newest sql Questions

Q&A for professional and enthusiast programmers

How to check the quality of a data file for data mining or further use? [on hold]

can someone tell me how to evaluate the quality of a data file ..?? What procedure is widely used to check the data Accuracy, Completeness, Consistency, Timeliness, Uniqueness, Validity and others ...

How to use NOT EXISTS in SQL Server in my case?

I want to retrieve some data from one table which is not present in another table. #tempLastSold table records (actual records 3000) ItemID ------ 9 41 43 45 65 68 79 5773 5834 5838 ItemRelation ...

Is this tutorial wrong?

While looking over a tutorial on the Flask module I came across something that i need to confirm is incorrect which is this https://www.tutorialspoint.com/flask/flask_sqlite.htm finally: return ...

IT is possible that ID with auto increment can generate a value to the column AS(SECTION a\B? if id<=10 on section A and >=11 on section as B

iM really having hard time analyzing on how to arrange it in php ; wpostid fpostsection w10 w11 sql.mysql-queryinsert into tbl-name id10valuessectionab

Output all data from a SQL database in a styled manner

I am trying to output all data from a database in a styled manner. It doesn't seem to be complying, though. Here's the code: The way I'm trying to output: <?php include 'database.php'; $sql =...

MySQL Nested query formating

I have a database with 3 tables, A VOLUNTEER table, a TRAINING_EVENTS table, and a TRAINING_INSTRUCTOR table. The VOLUNTEER table contains in formation about a person marked by a auto incremented ...

How to get laravel DB connection to php connection?

I need to receive laravel DB connection to variable to make concrete pure SQL php demands on a database. Desired code: <?php // this is not working $conn = DB::connection(); // Check connection ...

Doctrine: many to many join table with multiple columns to one table

I have one Entity with three categories: Primary, regular and sub. All categories come from the Category entity. If it were one column, I'd use a many-to-many join <many-to-many field="...

validate group level data with rules table

I have data structure rules in a file. And input file data should follow these rules and if dont then needs to be captured. Rules are given below DataRecord|GroupNum|GroupDefination|...

SELECT funcionario.name WHERE COUNT() > AVG() GROUP BY funcionario

I wont to SELECT funcionario.name WHERE COUNT() > AVG() GROUP BY funcionario funcionario = Employee cliente = client SELECT funcionario.nome FROM cliente INNER JOIN funcionario ON cliente....

Get ID from name with Access DLookUp function

Long story short I need to DLookUp an ID based on the name of a record. In this case I need to get the ID of a city based on it's name. When I try DLookUp("ID","Cities","Name = London") it says it ...

Create alias for SQL server to use in query

My SQL server instance name is in the format: 'My-Server\InstanceName' I want to give the server the alias 'InstanceName'. I did this in the Configuration Manager. When I connect to the server, I'm ...

Is there a way to trigger an event when other users update to a table?

Is there a way to trigger an event when other user(s) in network either update or insert a record into SQL table? I could read the table from the database every few seconds then compare the data to ...

Select most popular track for a playlist in a playlists table

I am creating a summary table with the stats of all my playlists with the following fields: PlaylistName LatestTrackAddDate NumberOfTracks TracksPlayedCount NumberOfArtists MostPopularSong I can get ...

SQL nested aggregate wage by quarter

I am trying to aggregate wages for worker for 8 quarters. As columns, have employee id quarter (1 digit int) year (4 digit int) quarterly_wage year_quarter (string i created from quarter and year) ...

Create a table in sql that has an enumeration value that can be given only in one entity

I have the table Person that has the attribute job that is enum-like and its values are : employee, director, manager etc but only one entity has the value director. How can I declare correctly the ...

How to import large sql files that would take more than 300s on phpMyAdmin?

I was trying to sql file - a big one (989MB) but I got this: ´Fatal error: Maximum execution time of 300 seconds exceeded in C:\xampp\phpMyAdmin\libraries\dbi\DBIMysqli.class.php on line 261´ I even ...

Select id and its count in MySql/DQL (symfony query builder)

I'm having trouble figuring out the logic behind this query. Suppose we have a table post_bump(post_id,user_id) I want to result set to be - post_id, Number of times this post Id is in the table I ...

Connection String in to access using oracle syntax

Is there any way i can connect to my access database using C# and process oracle syntax querys? my connection string now is : string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data ...

Error 1072 MySQL

I keep on getting error 1072 when trying to add a foreign key attribute and linking my attribute to another table. I've tried different ways of writing this but I keep on getting the message that "...

show different row and column data in one column using sql query

My tabular data looks like DECLARE @Tab TABLE(Name VARCHAR(10), VAL INT) INSERT INTO @Tab VALUES('A',25),('B',30),('C',236),('D',217),('E',19) SELECT * FROM @Tab I want to show my result as: Total:...

PHP 7 - How to access variable in another PHP tag

I've recently switched my PHP version from 5.4 to 7.1. The problem occurs when I try to connect to a database using a variable that is declared at the beginning of the file. The code is structured ...

Trying to get property of non-object - PHP

So I'm trying to get the teacher_id that is corresponding to the teacher's first and last name that the user has entered, but when I try to get the teacher_id it outputs Trying to get property of non-...

Reformat sql to show rows where main query returns null

Consider this sql: SELECT DATE_FORMAT( Orders.Timestamp, '%Y%m' ) AS Period, SUM(Price) AS 'Ordersum per month and organisation', Orders.Organisation, ( SELECT SUM(Amount) AS Returns FROM ...

groupby and store as dictionary string in hive

So, I have a table as user_id, product, price 12, foobar, 1.2 12, foo, 2.2 13, baz, 2 14, biz, 20 14, buzz, 21 and so on.. I want to group by user id and basically store as following ...

How to sort SQL Column Primary Key

SQL Hello guys, Please check the image above, how do I make sure that the "C10" will comes after "C9" Thank you

Mysql aliasing error in nested query

I have a database with 3 tables, A VOLUNTEER table, a TRAINING_EVENTS table, and a TRAINING_INSTRUCTOR table. The VOLUNTEER table contains information about a person marked by an auto incremented ...

How do I get all the courses and grade a user is enrolled in in Moodle?

sorry I'm new to Moodle, and the documentation is a little confusing. Given a userid, how do I query the database to get all the courses and grades for those courses for this user? I feel like it ...

Paste SQL-staement from clipboard containing image as byte[]

I'm user of an application with an Access backend. The application allows me to fire SQL-Statements via textbox against the database. That's working. It's also working to let c# convert a jpeg to ...

This code is vulnerable to sql injection?

I need help please! I need to know if this code is vulnerable to sql injection and how to exploit it: <?php if ( isset($_GET['id']) ) { $user_id = $_GET['id']; $query = "...

Get trending posts from database - symfony query builder - MySQL

I'm trying to make a query which has to combine information from 2 different tables and I'm having trouble with the logic. Here are my tables,I'm excluding some of the irrelevant info post(groupId, ...

Best practices: Should a query rely on existing client-side loaded data?

In the context of a debate I'm having with a coworker: Let's say we're loading categories on a certain page. Then there's a search function that allows you to load a category's items on the same page....

Best way to Re-Use a Cursor in PL/SQL

I'm building a program that will repopulate an Employee's new record based on his/her old records. Just a sample concept: x_table holds the employee records. Record with ID 1 is the initial record and ...

How to SUM by group where column has certain value

I have a data table like this | start_date | end_date | sales | is_finished | |:------------------------:|---------------------:|:------------:|:------------: | 2017-...

Inserting current user id into another table PHP

I am fairly new to PHP and am not sure how to do this. I have two tables: owner (ownerid(PK), username, password) venue (venueid(PK), owenerid(FK), venuename, location, number) owner ...

Convert text column, with several formats, to date column in MySQL

I have a column, named 'ActionTime' with varchar entries of the following format, either: '14/02/2016 5:05' or '14/02/2016 15:05' I want to create a query that will return a new column with the ...

C++ SQL, How to check the insert/update/delete statement success

Connection *con = getSQLConnection(); PreparedStatement *pstmt; ResultSet *res; pstmt = con->prepareStatement("INSERT INTO `user` (`LoginID`, `Password`, `Name`, `Email`) VALUES (?,'password','...

How to identify customers and suppliers on sql query

Hello Stack Overflow community! I am hoping someone can help pass along some advice on if this query looks ok and if there could be any improvements, and also how I can go about identifying whether a ...

UPDATE column using COUNT

I want the parameter 'HoursPerWeek' to Equal the number of pupils with a specific Teachers ID. I'm really lost on how to go about this. CREATE PROC spUpdateTeachingHoursAndWages AS update Payments....

SQL Interview Test

Having been given the following question as part of an interview I am keen to know the optimum solution. The question has been edited so that it is not identifiable. Question Table 'transactions' ...

SQL performance issues, need help optimizing this query if possible

I am not a SQL expert and need some input. I have the query below which takes over 2 hours to run and consequently times out. Company policy is we cannot alter the timeout period of a SQL query to be ...

How to repeat column until next value is encountered

I want to repeat the category column until the next value is encountered. Below is the structure of the table: Category Term Date -------------------- -------------- category1 a 12/...

HQL Query most recent timestamp in Many to Many relationship

DB A B A_B ----- ----- ------ id id A_id name time_stamp B_id desc Models A B ...

Query not giving poper output when using cursor

I have a PL/SQL block where I am trying to get the count of filled and not filled values for each column of a table i.e. "demo_table". select count(*) into v_count from demo_table where owner='...

MySQL Workbench 6.3 CE

Could not start server: error(10054, 'An existing connection was forcibly closed by the remote host') 64 bit os x64 bit processor windows 8.1 Downloaded from here https://dev.mysql.com/downloads/...

access 2013 query replace null to 0 does not work?

I'm trying to create a query which I inserted some formulas but it has no result if there is any NULL in cells involved in a formula. I tried to replace NULL to 0 (not necessary to show the number 0, ...

SQL query for build inbox of messages

Help with an SQL Query: I want to get the last message of every conversation between client and helper. Based on same clientId lets say clientId = 1 but different helperId. What I am trying to achieve ...

How to get 2 most recent values in postgreSQL in one row?

I have this table of items in order: orderitemid orderid itemid quantity price createdate 1 1 12 5 15.5 2016-12-04 11:35:02.06629 2 1 17 ...

Fetch rows of two set of ids each, having given condition

This is similar to my last question, but now I have change in the requirement, so I am posting as a new question. I have following sql schema and the sample data; CREATE TABLE items ( id int(11) ...

How to create temp table using Create statement in SQL Server?

How to create a temp table similarly to creating a normal table? Example: CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype, .... );
Translating... 0%