Questions tagged [sql]

Structured Query Language (SQL) is a language for querying databases. Questions should include code examples, table structure, sample data, and a tag for the DBMS implementation (e.g. MySQL, PostgreSQL, Oracle, MS SQL Server, IBM DB2, etc.) being used. If your question relates solely to a specific DBMS (uses specific extensions/features), use that DBMS's tag instead. Answers to questions tagged with SQL should use ISO/IEC standard SQL.

Filter by
Sorted by
Tagged with
0
votes
0answers
3 views

How to do a write a JPQL query to find records not found in this join?

For the life of me, I can't figure out how to construct this JPA query. I need to find TransactionLogs which have not been transmitted under a given SyncSendingConfig, ordered by ID. Researching it ...
0
votes
1answer
17 views

Error: can only concatenate str (not “list”) to str

I am trying to import txt file into sql, but i have an error: TypeError: can only concatenate str (not "list") to str My code: import psycopg2 con = psycopg2.connect( host = "", ...
1
vote
0answers
8 views

Hibernate: specify the size of char column in annotations

I have a class like this, with a String field that can contain a lot of text: @Entity @Table (name = "books") public class Book { ... //long description - exceeds char(255) limit private ...
0
votes
1answer
9 views

INITCAP in MariaDB

I am currently trying to check that every values that are inserted into my MariaDB table the 1st letter of every word in uppercase, so I tried to use CONSTRAINT nombreok CHECK (INITCAP(nombre_director)...
-2
votes
0answers
12 views

how to Write a MySQLfunction allowing to display a single line in case of doubling caused by a request [closed]

how to Write a MySQLfunction allowing to display a single line in case of doubling caused by a request
0
votes
0answers
9 views

Presto SQL want to use a function on each of all columns, how not to list them one by one?

Let's say I want an output of something like: Is it possible to replicate this without explicitly writing out all 100 column names? select main, count(distinct col1), count(distinct col2), ... count(...
0
votes
4answers
30 views

Codeigniter MySQL select max using varchar type value

I want to select max auto_no from the following varchar type column in my codeigniter model +------------+ | auto_no | +------------+ | 2020-00821 | | 2020-00822 | | 2020-00823 | | 2020-00824 | | ...
0
votes
1answer
16 views

How to format integers slighty left in sql*plus?

I have a question on how to format the values of a column to be slightly left justified=right.. Here is what i have: The format Im looking for is justified right and the number should be in format of ...
0
votes
0answers
22 views

how can I add or update values with select count (*) and parameters SQL table and c#?

I'm trying to update information in the SQL table with this code using c# language, the first section is to count all data. the second section is to run my update Query/function the event is : ...
0
votes
2answers
22 views

Selecting users who are in the same group with “name”

Users id username 1 ryan 2 mike 3 annie 4 lisa Groups id name 1 football 2 hockey Permissions user_id group_id 1 1 1 2 2 1 4 2 So I'm ...
0
votes
0answers
15 views

Creating triggers without SUPER privilege

I am trying to create a trigger in a MySQL database. However, I'm not allowed to: #1419 - You do not have the SUPER privilege and binary logging is enabled (you might want to use the less safe ...
-1
votes
0answers
18 views

self-join (inner join) generates cartesian product

Data origin OP_CARRIER_AIRLINE_ID ATL 19790 ATL 19790 ATL 19790 ATL 19790 ATL 19790 ATL 19790 ATL 19790 ATL 19790 ATL 19790 ATL 19790 BWI 19790 BWI ...
0
votes
1answer
14 views

How to map dynamic excel rows to sql database columns

I am trying to import an excel using Laravel with dynamically changing columns(names as well as sequence) . I am looking for a way to map these columns against Sql db columns.
-2
votes
1answer
22 views

Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates

SELECT DISTINCT(CITY) FROM STATION WHERE CITY LIKE '[AEOIU]%'; Why this query is not working?
-1
votes
1answer
15 views

Parent/child join query with and without conditions on the child

I have a simple one-to-many parent/child relationship where I basically want to perform a left join to display all parent data in a table on the client: SELECT p.*, c.* FROM parent p LEFT JOIN child ...
0
votes
1answer
24 views

How to pass table as a parameter and populate that table using plsql procedure

I want to populate a table using plsql. It will get table name as a parameter and insert records that are already exist the table. The problem is when there is primary key in the table there can't be ...
0
votes
1answer
22 views

write a postgreSQL query to update a json column

I have a table T with a column J of type json, and one of it's row contains value {'SELECTION':'A'} I want to change it to {'selection':'A'} i.e change the key of the JSON. Any one has experience?...
-2
votes
1answer
34 views

Displaying SQL Data in a HTML Table [closed]

so I've been working on a small Project of mine, and im currently testing some things, but im kinda stuck with displaying SQL Data entries in a HTML Table. I tried a few things i found in the internet,...
1
vote
0answers
30 views

fill in the missing data with a query in oracle

The code is very difficult for me, so this is not the first time I have been writing for help. The situation is depicted in the demo version of the code https://dbfiddle.uk/?rdbms=oracle_18&fiddle=...
1
vote
0answers
21 views

JS array not being passed to php file?

I have read through many similar questions and had a look at many ajax php tutorials. But I still cannot find for what reason my array is unable to be passed to my PHP. I post my JS array here: ...
0
votes
0answers
26 views

How to update var binary to existing SQL columns? [closed]

I have table, City: my table Pic column type is varbinary(max). I Update my pic column with this code and work(for 1 pic): SqlFileToDB = "UPDATE City SET pic = 0xwed323422222222.... WHERE ...
1
vote
1answer
25 views

how to get data by date from sql database

I have this code. In this code getting data by views. But, I want to get data by date in create recent. Like this code $recenttuners = $db->rawQuery('SELECT user_id, date AS count ...
0
votes
1answer
22 views

SQLiteDatabase.query orderBy cluase: “SELECT”: syntax error (code 1 SQLITE_ERROR):

I found the below syntax for orderBy clause: String orderBy = "SELECT * FROM " + TABLE + " ORDER BY " + COL_NAME + ";"; but it gives this error: E/SQLite Exception: near "SELECT": syntax ...
0
votes
1answer
15 views

Oracle Apex - How can I use dynamic actions to update List of Values on change action?

I am looking for someone familiar with Oracle Apex who could help me solve this problem. I'm trying to cause my LOV to update itself (in a form) after I pick a specific date from datepicker. I have a ...
0
votes
0answers
15 views

How to select entity with join using EntityManager and CriteriaBuilder having @ManyToOne relationship?

It is just an exercise to understand how to use CriteriaBuilder and EntityManager with join. I want to join class Product with Customer and select each product that have the requested customer_id. I ...
1
vote
2answers
50 views

Check if the first or second condition exists

I have a little problem selecting queries, namely when I want to check the first condition with the code below select * from VL_Faktura_Queue where FAK_KundenNr=127849 AND (FAK_BoMatNr LIKE '%verk%' ...
-3
votes
0answers
26 views

I have multiple entry and exit status of a person. how do i get the current status of a person [closed]

above is the sample for user status it can be either inn or outt. I am trying to get his live status. For epitome, suppose there are total 5 persons, 2 persons are in room and 3 are out of the room. ...
0
votes
0answers
14 views

Database Model selection Relational vs Non-relational databases?

I have been reading up on SQL vs No-SQL style database setups and from what I understand depending if you need a more flexible approach ex. in prototyping an MVP where the database structure can vary ...
0
votes
0answers
19 views

How optimization select in Msql 8? [migrated]

i have a problem with optimization select on Mysql ver 8.0.17 I'd like to optimize a query that takes 60 seconds to run the first time, but when I run it the second time it takes less than a second (...
0
votes
4answers
54 views

How to convert nvarchar to numeric in SQL Server

How to convert nvarchar to numeric? I got this error: Error converting data type nvarchar to numeric. This is my query SELECT strIpay88Amt, CONVERT(NUMERIC(18, 2), strIpay88Amt) AS ...
0
votes
2answers
37 views

How to create calculated columns in SQL with sql-window functions?

So I am working on this solution that involves fetching input of 3 columns say 'Year', 'Month' and 'Spend' and use them to create another column 'Year Total' using logic that imitates SQL-window ...
1
vote
2answers
44 views

Query is executed with 0 rows affected, but when trying to run directly using the database it works

I have the following Microsoft Access database structure: I am trying to create a C# function in the class book: Return(), that is used to return the book from the client that borrowed it. This is ...
0
votes
3answers
39 views

Get most frequent value from a windowing function

I have a SQL table that looks like: user_id role date 1 1 2019-11-26 21:20:54.397+00 1 2 2019-11-27 22:46:28.923+00 2 1 2019-12-06 22:17:53.925+00 2 3 ...
-1
votes
1answer
35 views

How to fix the SQL error “Error converting data type varchar to numeric”?

I am selecting records from a SQL Server database but result says that the query completed with errors and then error I get is Error converting data type varchar to numeric In my query I am ...
0
votes
2answers
32 views

(SQL Server 2017) I get error Msg 8152 and I don't know why

I have no idea why, but I am getting the error Msg 8152 (in SQL Server 2017) after trying to insert something like INSERT INTO Users (usr_name, usr_pwd, usr_thing1, usr_thing2) VALUES ('ticko', '...
0
votes
3answers
25 views

how to create pl sql function to Checking if data exists in database or not

I am trying to create a function that tells whether data exist in database or not. Trying to solve this using cursor if data exist then data will be fetched from database and value of temp will be ...
-1
votes
1answer
21 views

Can anyone please help me in the sql query to extract the particular part in the string [closed]

String='DSB abcdefcvf Ref No.12345rty6789 and abcdfgrn trgdy 12345 and thfgyrhud 345623' Result should be like: Column 1 - 12345rty6789 Column 2 - 12345 Column 3 - 345623
-1
votes
0answers
11 views

How to add new value in specific column in phpmyadmin database table through python [closed]

Here I made a database named "Demo" in that database I have "Test" Named Table, My Database should like this And while I click on the update button from frontend I need output like this Can anyone ...
-5
votes
0answers
25 views

How would I go about displaying a user's “Account Balance” from SQL in HTML format?

I searched everywhere and could not find help for this topic. I am creating a credit-based IMEI checking system, and I need help with something. I know this is a big beginner project but I am eager ...
-2
votes
0answers
12 views

Problema com query para filtrar diferentes campos numa mesma tabela SQL [closed]

Tenho uma tabela com logs de uso do GSUITE e gostaria de filtrar algumas métricas uma delas é a que segue e que estou com problemas para realizar. (Sou iniciante em SQL) Procuro as seguintes ...
-2
votes
2answers
31 views

FROM keyword not where to be expected

I'm getting the error ora:00923 in Oracle in this query: select trans_dt case trans_type="CR" then "Credit" else NULL end as "New" FROM bank_transaction;
-2
votes
1answer
12 views

How can i count different 'ip' for same 'ads' with combining same 'adv_id' into one [closed]

i have a table for finding which ip has clicked an ad but when i want to display 4 ads on my main page with first one having highest ip's count and going on. my table
0
votes
1answer
20 views

Cannot resolve the collation conflict between “SQL_Latin1_General_CP1_CI_AS” and “Chinese_PRC_CI_AS” in the equal to operation

If I INNER JOIN tblMachine on b.strMachID = tblMachine.strMachID this error appears: Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Chinese_PRC_CI_AS" in ...
0
votes
2answers
36 views

SQL include record every nth record in query results

QueryA QueryB Col1 Col1 1 a 2 b 3 c 4 d 5 e ... 100 I want to take the results of QueryA and for every nth record (let's say every fifth ...
0
votes
4answers
41 views

Count 2 columns from join query in Oracle

I have a query which returns values from one column and splits into two columns based on the value. What I'm trying to achieve now is getting a count of each value for each column. I've tried a ...
0
votes
2answers
29 views

Select/ Updated last inputted sql row

I feel like this is a very easy problem, but I have been trying to figure this out for many hours with sqlite3. All I need is to retrieve the last row of data input into the table and update it with ...
0
votes
1answer
23 views

Mysql table design to run multiple tasks and notify users [closed]

I am trying to figure out how to best design the database tables. Any help is appreciated. Multiple users can select all items in the list or select only a few items and perform different operations ...
0
votes
1answer
16 views

How to get the points for a Lorenz curve plot with SQL?

I'm working with BigQuery, and I'm interested in plotting a Lorenz curve (for inequality, related to the Gini coefficient). How can I produce the data for a plot like this with SQL? The curve is ...
-1
votes
1answer
24 views

Postgres SQL equivalent of spark window.partition with row_number

Basically, what is the postgres equivalent of this spark command val win = Window.partitionBy("department", "state").orderBy(col("salary").desc) val h = df.withColumn("row", row_number.over(win))....
-1
votes
0answers
25 views

How to get rid of a negative value using SQL and PHP?

My code is: if ($clan_exist_check['clan_naam'] && $clan_exist_check['clan_silver'] < 1 || $clan_exist_check['clan_naam'] && $clan_exist_check['clan_gold'] < 1) { echo '<...