Skip to main content

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.

sql
1 vote
1 answer
18 views

SQL not allowing deletion of related data

In SQL I have: CREATE TABLE Customer( cust_id INT NOT NULL PRIMARY KEY CHECK (cust_id > 0), full_name TEXT NOT NULL, phone TEXT NOT NULL, ...
Moran's user avatar
  • 11
0 votes
0 answers
7 views

first 2 makes query slower than when I use first 1 in sql query in informix database

I have a query on a huge table (126738484 records) on an informix database server; this query returns only one record. when I use "first 1 " in the select statement, it runs quickly but ...
Saina Mohamadyari's user avatar
-1 votes
0 answers
18 views

ER_BAD_FIELD_ERROR in SQL

CREATE DATABASE IF NOT EXISTS RAIL; USE RAIL; CREATE TABLE IF NOT EXISTS train ( t_id INT NOT NULL AUTO_INCREMENT, t_rating INT NOT NULL, t_name VARCHAR(20) NOT NULL, t_price INT NOT ...
Harsh's user avatar
  • 11
0 votes
1 answer
13 views

laravel Eloquent ::has() QueryException on different connection

I have two databases, db1 : users table db2 : infos table Each table I created has a Models, and I set a different connection for each one: User.php => protected $connection = "db1"; ...
none's user avatar
  • 45
-1 votes
0 answers
22 views

Check if a table has any records [duplicate]

Considering a situation to check whether a table has any records or not, Is there any difference in the performance or execution speed among the two following queries? If yes, what is the logical ...
Amir Monfared's user avatar
0 votes
2 answers
38 views

Using arrays in `WHERE IN` statements

There are the following table structures and data: CREATE TABLE t_source_category ( id INT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, label varchar(255) NOT NULL, path varchar(255) NOT NULL, ...
SageJustus's user avatar
-1 votes
1 answer
26 views

Why does this SQL command give the error "Unknown statement type"? [closed]

I'm new to SQL and do not really understand why this: INSERT INTO users (highscore); VALUES ('1'); gives me an error. Why does this not work? I'm trying to save my high score in the database so I can ...
GeistFan's user avatar
-4 votes
0 answers
34 views

Spotting missing (null) rows in a table

I have three tables: Guests Meals Dates Most guests place three orders a day within a week period which is set up as a CTE with the following code: with Dates(Date) as ( select cast(@date1w as ...
Dan's user avatar
  • 49
-4 votes
1 answer
40 views

How do I split a string with inconsistent data?

I have some imperial distances (miles/furlongs/yards) in a column which I am looking to convert into just furlongs. However, the data is inconsistent. Sometimes there is a furlongs value, sometimes ...
UKJonA's user avatar
  • 1
0 votes
0 answers
29 views

How do I generate rows of predefined values from a SELECT statement? [duplicate]

In SQLite I want to return a list that I type in myself (for further left join SQL commands): ABC DEF GHI Not existing in any table but manually entered strings (like how SELECT 'ABC' returns ABC, ...
Eric F's user avatar
  • 919
1 vote
1 answer
28 views

SQL query to update duplicate data

I had a bug in my code which created a lot of new users with the same email (id was the PK), and this caused my Usage table to save data of the new ID that was created. User table: user_id | ...
laskdjf's user avatar
  • 1,182
0 votes
1 answer
23 views

How To use QSqlQuery::bindValue

I have this snippet : int id = m_AddItemCandidate->getId(); QString s = "INSERT INTO studied_substantives (subst_id, no_singular, no_plural, meaning) "; s = s + "VALUES(:id,...
Alain Bertrand's user avatar
1 vote
1 answer
26 views

How to use one PS dataset in a WHERE-OBJECT of another dataset

I have been using PS for about 10 years. Today I am stuck with finding a solution to a problem where I want to have items used in a WHERE-Object loaded from a SQL table. From what I have read, I need ...
veeduber's user avatar
0 votes
0 answers
34 views

How can I fix this RLS policy issue with Supabase on .insert()?

I am in the process of creating a habit tracking app and am using Supabase PostgreSQL. I am implementing RLS in the habit table but cannot for all that is good figure out this issue. On the click of ...
pmelan's user avatar
  • 1
-1 votes
2 answers
46 views

Convert multiple MYSQL rows to only one array column

I have a simple database with the user and the country tables. Which user belongs to only one country. Which country has a list of users. Right now Im using group_concat (code below) and its working ...
Jeú Casulo's user avatar

15 30 50 per page
1
2 3 4 5
44852