Tree as data collation in SQL (Mysql)

I have two tables in my database Table A with columns user_id, free_data, used_data Table B with columns donor_id, receptor_id, share_data Basically, a user (lets call x) has some data in his account which is represented by his entry in table A. The

Complex query join error

I tried to run a complex join query on SQLFiddle but kept getting errors. Wanted to print all the main attributes on the select statement. Got stuck for the past few days. A helping hand will much appreciated. `CREATE TABLE Customer` `(CustomerID INT

problem using not exist in SQL

Not exist not working. I have a query which is fetching 10k rows... now there are 237 rows which I do not want to be retirevd in my final result but when I am using not exist it is fetching the same no. of rows that is 10k I have used teh following q

is this derivation of functional dependence correct?

Let's say, I have two functional dependencies A -> EF B -> GH Is there any axiom through which we can deduce the relationship below? AB -> EFGH You can derive: AB -> EFGH from: A -> EF B -> GH with the following steps: 1. A -> EF (by

jOOQ - support for JSR310

Does jOOQ provide support for JSR310 in combination with PostgreSQL? In particular, I am trying to use the following classes: java.time.Instant java.time.LocalDate java.time.LocalTime java.time.LocalDateTime I am storing in the following data types (

Break a string into fixed-length records in Oracle

How would I break a string such as this: BPR*D*895.11*CACHCTX*01*062001186*DA*2533167775*0011111114**01*021000089*DA*0007777777*20150317*VEN~TRN*1*1234600*0987654321~~DTM*097*19980205~N1*PR*123 EASY PAY 1*1*123000000~N3*1234 MAIN STREET~N4*ST. LOUIS*

Can not find mySQL query error

Rediculous but I cant find error in this request SELECT * FROM diploms LEFT JOIN student ON diploms.student_id = student.student_id LEFT JOIN group ON student.group_id = group.group_id LEFT JOIN speciality ON group.speciality_id = speciality.speciali

how to assign an int value to the SELECT database string

I used DataAdapter for use SELECT common to choose rows of Table OleDbDataAdapter objDataAdapter = new OleDbDataAdapter("SELECT * FROM Table WHERE dayNum = @dayNum", objConnection); //here dayNum must be equal to 10; dayNum = 10 I want assign an

Storing zips in SQL Server

I would like to store a zip file as a column in a SQL Server table. When I open this zip in notepad++, it has null characters in some places. What datatype can I use for the SQL Server column to store this zip? I have tried using varchar, nvarchar, t

Oracle procedure, How to select a record

i'm writing stored procedore in oracle. I'm using Toad 10.6. I wanna result get a record. Passing a parameter, this is id. Table TTEST Columns: {ID, VALUE}. My code: CREATE OR REPLACE PROCEDURE GB.TTEST_GET ( id NUMBER ) IS a NUMBER; BEGIN --DBMS_OUT

Separate record (string) in multiple fields

I've got strings with text like this: "Australia/Sydney/Day 2738/Jose and Carlin" I need to split it to several columns. But here's the tricky part. String also may be looks like "UK/Manchester/Centre/Day 627/Lucas and Nicole". All str

Delete the value with relational table trigger vs

How do you delete values with a relational database for connected tables. Example of Movie Database: Movie Table -> Movie_has_Genre Table -> Genre Table If I delete a Movie I would want to delete all the rows of Movie_has_Genre table where the forei

Find the highest number in a column

I am trying to find the highest number in a column out of several results, I am trying to use the following code but it isn't working as expected. If I have records numbered 1 to 7 I want to pick 7 as it has the highest number. if (isset($_GET['quest

Join conditionally in MySQL

I have a table called USERS and a table called ADDRESSES, as well as an ADDRESS_TYPE table. Each user can have multiple addresses. SELECT * FROM USER INNER JOIN address ON address.userId = user.userId INNER JOIN address_type ON = addr

SQL: How to Combine the Results of Multiple Columns Using Where

Simple, I want combine results when using WHERE LIKE in multiple columns $query = "SELECT T.Id_Servicio ids, C.Nombre cliente, T.T_Atencion atencion, M.Nombre marca, P.Nombre producto, SU.Nombre subproducto, T.Observaciones obs, T.Estado edo FROM t_s

SQL Server: CASE does not work

SELECT a.componentId, a.uniqueCode, 'sd'= CASE WHEN RTRIM(LTRIM( IS NULL OR RTRIM(LTRIM(b.uniqueCode)) IS NULL THEN isnull(b.uniqueCode,'')+isnull(,'') WHEN RTRIM(LTRIM( IS NULL AND RTRIM(LTRIM(b.uniqueCode)) IS NULL THEN isnull

Join the last record based on TimeStamp

I have a access log, which records usernames and a timestamp at various points in the application. I want to see if I can approximate the amount of time they are spending in the application. Basically I want to join each record to the last access rec

Bad query for the 0.1 field on the rawQuery () cursor

I am pretty new to android, and I have the following problem. This is my code where I'm trying to get data from the database into my list. private List<Model> getModel(int a) { dbHelper = new DbHelper(this); db = dbHelper.getWritableDatabase(); Log.

size limit for sql_variant exceeds

I am trying to save image from fileupload control into the database public Byte[] bytes; Stream fs = FileUpload1.PostedFile.InputStream; BinaryReader br = new BinaryReader(fs); bytes = br.ReadBytes((Int32)fs.Length); SqlDataSource2.Update(); protecte

Mysql insert with foreign key referring to the primary ID

Let's say I hava a table object: id, primary key auto-increment obj_id, foreign key ( val, integer Is it possible to insert a record with obj_id = id. Not having an error with foreign key constraint? Insert into object (val) values (123)If

The query works in MySQL and not in Oracle

The following SQL statement works in MySQL but not with Oracle: SELECT *, MAX(COLUMN_A) FROM table_xyz WHERE COLUMN_A <= 100 GROUP BY COLUMN_A Oracle complaint: "FROM keyword not found where expected" actually the statement was incorrect, we

How to optimize a MySQL query containing a subquery?

I have two tables, House and Person. For any row in House, there can be 0, 1 or many corresponding rows in Person. But, of those people, a maximum of one will have a status of "ACTIVE", the others will all have a status of "CANCELLED".

T-SQL query to check the number of existences

I have next approximate tables structure: accounts: ID INT, owner_id INT, currency_id TINYINT related to clients: ID INT and currency_types: ID TINYINT, name NVARCHAR(25) I need to write a stored procedure to check existence of accounts with specific

How to best represent rational numbers in SQL Server?

I'm working with data that is natively supplied as rational numbers. I have a slick generic C# class which beautifully represents this data in C# and allows conversion to many other forms. Unfortunately, when I turn around and want to store this in S

Query to check the index on a table

I need a query to see if a table already has any indexes on it.On SQL Server, this will list all the indexes for a specified table: select * from sys.indexes where object_id = (select object_id from sys.objects where name = 'MYTABLE') This query will