Category "sql"

How can we assign a field of user table say id that is primary key, to another table as a primary key? using hibernate

See I dont want any mapping but what I want is just a simple thing that is.... I have two Entity Tasks(taskid,taskname.....,userId) User_Credentials(userId,pass

SQL FOREIGN KEY ERROR (errno: 150 "Foreign key constraint is incorrectly formed")

Hi I have this three very simple tables but I can't fix it to get the right format of foreign key. CREATE TABLE company( company_name varchar(30) UNIQUE NOT NUL

SQL referrals view

I have a table with users: id referred_by_user_id ----------------------------------- 1 null 2 1 3 1 4

How do I loop through alll columns using Jinja in DBT?

I want to iterate over all the columns using dbt.

Can SQL be injected when the input is hashed?

The passwords and my SQL database are hashed. If the input is hashed, can the field be injected? The hash is SHA256. My command is to be: SELECT true FROM acc

How to search tree structure with multiple types with TypeORM

thanks for reading and provide any suggestions or any keyword I can do more research. Quite new to TypeORM and have an issue on searching the tree structure wit

Concatenate the contents of two rows into one column (SQL DB2)

as it says in the title, I need to return two records but in the same column, for example (I clarify that the following code does not work, it is only to unders

PGSQL query to get all records of a column containing line breaks

What is the shortest Pgsql query to get all records that contain a line-break in a given column ?

Azure SQL: generate JSON with column as key

I have the below data in my sql server table Name Value ValueHash country aaa zzz lastname ccc yyy email [email protected] xxx firstName bbb www And I want the below Js

Subtracting rows based on condition

Suppose I have a table that looks like this: OrderNumber OrderType 1 D 1 D 1 R 2 D 2

Error when trying to use count and group by

Here is my query: SELECT DISTINCT takes.semester, takes.sec_id, takes.course_id, instructor.name, COUNT(takes.ID) FROM takes INNER JOIN teaches ON takes.cour

DBMS ERD Design

I am planning out an application's database. I have an employee table. I want to store every employee's education degree. Adding an education column to the empl

MySQL How to join 2 tables and get a combined response

I have 2 tables projects and images. My goal is to get all images of a project and get this kind of response. { "data": { "id": "this is project id",

how to display columns in specific order, according to field value in MS Access

I want to display a query but the column order needs to be sorted according to the value in the column, field with greater value as column 1, then second greate

SQL Query to get the last unique value from a column

I have a SQL table with the following columns: id | created_at I want to get a dictionary of all the unique id's and the latest created_at time. My current quer

First time SQL query is taking More time from Spring Boot application

I have to fetch some records and then display in output. In my Spring Boot Application, I am using JPA Specification for creating Criteria and then calling repo

SQL returning all rows and count

I have 3 tables, Property managers, Addresses and Units. I'm trying to get all the rows using the aggregate function COUNT, but it only returns 1 row. I want to

MYSQL query that works out the total amount of days between different time periods for a payroll

I know this question may seem like a simple one and might have been asked before but what makes this tricky is how do I work out the total days for a payroll. N

SQL Server - Regex pattern match only alphanumeric characters

I have an nvarchar(50) column myCol with values like these 16-digit, alphanumeric values, starting with '0': 0b00d60b8d6cfb19, 0b00d60b8d6cfb05, 0b00d60b8d57a2b

Removing leading zeros from a string in SQL Server

i have removed all leading Zeros in my column but what if the same column has a space its replaced by '0'.. Example: batch number has 000123, 0000145 but when t