Select 2 unique column in a query

How can I build a query with records such that 2 columns are unique? This is my attempted code: Select x.a, y.b from table1 x, table2 y where x.id = y.id; 1 - a 2 - b 3 - a 4 - b 5 - c 1 - c 6 - a 2 - a should return this: 1 - a 2 - b 5 - c But t...
more »

2017-02-14 17:02 (3) Answers

Select sum with other table in SQL

How do I select sum with other table if I have data like below: Table Member MemberID Name DateJoin M0001 John 01/01/2015 M0002 Willy 03/20/2016 M0003 Teddy 02/01/2017 etc.... Table Transaction MemberID Tr...
more »

2017-02-14 06:02 (3) Answers

SQL Server Missing Backups

I'm trying to get a list of missing full backups, but I need this list to show me which user performed the latest backup. The problem is, I don't know how to filter that, since what I'm querying is returning all the last backups for each user. Examp...
more »

2017-02-14 03:02 (1) Answers

MariaDB 10.1 JsonGet_string

In one of our columns we store this example json string: [{"Name":"Pay Amount","Value":"0.00"},{"Name":"Period","Value":"3"},{"Name":"Client","Value":"TestClient"},{"Name":"Our Reference","Value":""},{"Name":"Pay Type","Value":"Test"}] We repeat ...
more »

2017-02-13 16:02 (0) Answers

Count Length of Digits Per Column Per Row

I generated the following table: CREATE table user ( user_id INT NOT NULL UNIQUE AUTO_INCREMENT, user_phone_number INT, user_city VARCHAR(32) NOT NULL, PRIMARY KEY (user_id) ); And I'm being asked the following: number of u...
more »

2017-02-13 03:02 (1) Answers

SQL - PostgreSQL - Find gaps in booking calendar

I am currently setting up a web based system to allow users to find availabilities of boats in a calendar. I am using PostgreSQL 9.6 A user should be able to say I want to find a boat available for three hours in the next three months between 08h00...
more »

2017-02-12 14:02 (2) Answers

Is this approach safe to use?

I'm fairly new to working with SQL Server and ASP.NET so I'm worried about SQL injection or other threats. I have a FormView referencing a SqlDataSource where the FormView has code-behind logic preventing unauthorized users from making changes to the...
more »

2017-02-11 17:02 (1) Answers

C# Creating and Populating an Oracle Database

To start i don't have access to the database, we hit a problem with our university account and waiting for it to be reset. How ever i do have code that is giving me some problems and frankly i'm not sure i have even gone about this in the right way. ...
more »

2017-02-11 17:02 (3) Answers

SQL JOIN Returning no values

I am working with 3 tables with the following Names and columns: *Table 1* **Users** UserID UserName UserTypeNumber 1 John 1N 2 Mary 1N 3 Doe 1N 4 Sullivan 2N 5 ...
more »

2017-02-11 15:02 (2) Answers

Using IsNull() in a WHERE clause

This query: SELECT sc.ContactID , c.Price , p.ParkID FROM tblc c JOIN tblsc ON c.ID= sc.ID LEFT JOIN tblp p ON sc.ID= p.ID WHERE (stuff = stuff) AND (stuff = stuff) Returns this: Contact...
more »

2017-02-10 17:02 (1) Answers

Alternative to dynamic SQL

I have a couple of stored procedures which use dynamic SQL. I'd really like to alter them so that they aren't dynamic, purely because they can be very annoying to troubleshoot and alter due to the error handling (clicking the error message doesn't ta...
more »

2017-02-10 12:02 (2) Answers

SQL conditional variables in select query

I'm trying to write an SQL query that uses the Nested Interval Hierarchy database model. --Given a parent Id, this query retrieves the position of the youngest child which can be inserted into the table SELECT TOP 1 --compute values based on the...
more »

2017-02-09 16:02 (1) Answers

<br> for textboxes and SQL

I have this SQL query that concatenates two columns SELECT comment = COALESCE(comment + '<br/>', '') + remark ,[id] ,comment ,remark FROM Product What I want to ask: if the records from this query are displ...
more »

2017-02-09 12:02 (0) Answers

Lazy order by/where evaluation

Edit It seems that a pure materialization can be stored as a column on the table and indexed; however, my specific use case (semver.satisfies) requires a more general solution: create table Submissions ( version text created_at timestamp ) ...
more »

2017-02-08 22:02 (4) Answers