All Questions
140,481 questions
0
votes
1
answer
32
views
Fetch data in two tables mysql [duplicate]
I am trying to fetch data between 2 tables but I am not getting any result!
Here is my code
SELECT daily_data.DataCount, handled.hand_over
FROM daily_data
JOIN handled ON handled.id = daily_data.id
...
1
vote
1
answer
50
views
are Sub query operators ( ALL and ANY) really needed, why do we need them instead of min,max and in operator
we are using subquery operator ( ALL & ANY ) along with a relational operator,
so instead of that we can just use MIN or MAX in case of numbers and IN in case of characters.
I want to know if ...
1
vote
1
answer
65
views
How to apply spatial index in my situation without using 'or' and 'union all'
I've been refactoring using the spatial index at Haversine,
I wanted to write a sql statement that checks posts within 10km with the point value (0,90) for information without distance, but I ...
0
votes
0
answers
47
views
MySQL / phpMyAdmin: Merge Two Tables by Matching IP — Add numberoftime for Existing IPs, Insert New Rows for Unique IPs [duplicate]
I have 2 tables 'error1" and 'error2' with the very same architecture
error1
id
IP
numberoftime
1
127.127
56
2
100.100
47
error2
id
IP
numberoftime
1
90.90
56
2
100.100
32
I would like to merge '...
-4
votes
0
answers
44
views
Why is LEFT JOIN skipping identical VARCHAR barcode values in SQL Workbench? [closed]
I have two tables in SQL Workbench, both
sales
Barcode(primary key for each sale)
other sales-related columns…
products
Barcode
product_name, price, etc.
I'm running a simple LEFT JOIN to append ...
1
vote
2
answers
103
views
SQL to join tables and get value from one table that has most recent date closest to date of parent record
I have two tables, one a parent of the other, let's call them CUST and CUST_ADDR. Each table is a history table, so each time a value in one of the data fields changes, another record is added with ...
1
vote
1
answer
72
views
stored procedure updates zero rows
I am creating a stored procedure that in theory should update roughly 13K items in my database. I am creating this on my own personal machine, thus the localhost and root username.
In theory it should ...
-3
votes
0
answers
28
views
Get count total time for particular task and particular user group by status [closed]
I have a MySQL table (task) where task_id assign_by, assign_to, task data saving through PHP script.
I want to make a MySQL Query where I want to get the number of task assign_to user
task_id
...
-3
votes
2
answers
62
views
Getting the date range [closed]
Id like to fetch the timestamp date range start date of the week
SELECT timestamp, SUM(name) AS tits
FROM amount_data
WHERE timestamp >= curdate() - interval 14 + weekday(curdate()) - 0 DAY and ...
0
votes
2
answers
65
views
Alter column in MySQL – correct script to ensure all previous attributes in the column are maintained?
I have a script that modifies from utf8mb3 to utf8mb4.
I know that in MySQL, if I have a table with the following structure:
CREATE TABLE foo (
name VARCHAR(100) DEFAULT 'Test' NOT NULL COMMENT '...
-4
votes
2
answers
105
views
Convert this Eloquent model function to a MySQL query? [closed]
I need to convert this Eloquent Model Function to a MySQL Query:
public function currentPrice(): HasOne
{
return $this->hasOne(Price::class)->ofMany([
'published_at' =>...
1
vote
3
answers
117
views
Unique constraint to prevent overlapping ranges? To make sure a BETWEEN statement for two columns will always only return one row?
We have two columns, id_begins and id_ends. We use a BETWEEN statement to select the row where a specific id number will fit between the values in those two fields (including the begins and ends ...
1
vote
3
answers
93
views
Create data-analysis about overlapped login grouped by time slot
I'm developing an internal dashboard and I have to show how many login sessions overlapped each other (the maximum of them), grouped by time slot (assuming the day is fixed, passed as a parameter).
In ...
2
votes
1
answer
65
views
MySQL query to retrieve a hierarchical structure while limiting each level of child comments to a maximum of 5 per parent
I have a comments table with id, parent_id, content, created_at, and other fields. I want to be able to select the root comments first (i.e., comments where the parent_id IS NULL), and limit them to ...
-6
votes
3
answers
78
views
SQL Query - To fetch record count based on not in condition [closed]
I have table A
ID
Code
100
S01
100
S02
101
S01
101
S03
102
S01
102
S03
103
S01
103
S02
103
S04
104
S01
104
S02
I want to get count of ids which have code S03 and ids with out code S03
Expected Result
...