All Questions
40 questions
0
votes
1
answer
69
views
MySQL/MariaDB recursive statement, Return empty if children do not match condition
I have tables like this in the database:
Category
id_category
id_parent
level_depth
1
0
0
2
1
1
20
2
2
21
2
2
22
2
2
30
22
3
category_product
id_category
id_product
2
200
2
201
2
202
20
202
20
203
20
...
1
vote
1
answer
358
views
How To Get First Parent By Child ID With MySql Query Or php?
I have this table:
id
name
parent_id
1
mike
0
2
jeff
0
3
bill
2
4
sara
1
5
sam
4
6
shai
5
I want to find first parent name,id by send id OR parent_id :
For example:
If I Send 6 id(shai) I want To Show ...
-1
votes
1
answer
68
views
Get SQL data individually for days between now and 30 days ago
I'm building an analytics chart where I need to display the number of visits for each day, for the past 30 days. I've tried using the loop below, but it fails to pull certain data and drastically ...
1
vote
3
answers
480
views
How to speed up query execution MySQL
You must fill out the form table 1 to 1,000,000:
Table view
CREATE TABLE `test` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , `value` INT UNSIGNED NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;"
...
1
vote
1
answer
430
views
Get last Left Child in binary tree in php
i am trying to get the last left child of sponsor id in a Binary tree.
Like: this is present situation(in picture), when id7 whats to add a customer(whose id will be 14) in his left side then it will ...
-2
votes
1
answer
58
views
PHP + MySQLi - no idea how to query DB to solve my problem
I've got the following MySQLi-DB:
╔═════════════╦═══════════╦════════════════╗
║ category_id ║ parent_id ║ name ║
╠═════════════╬═══════════╬════════════════╣
║ 28 ║...
0
votes
3
answers
953
views
How fetch all rows which are 10 min apart in single query in PHP MySQL?
I have table device which contain temperature values recorded and their time of measurement .I need to sample this data by fetching only values that are at least 10 min apart .(
ex if first row ...
-1
votes
1
answer
34
views
How to create PHP insert query based on selected timing
I want to create an insert query based on the selected start time, end timing and duration of the session. This is for an appointment table.
$start_time = 9.am
$end_time = 11.am
$per_session = 30 mins
...
0
votes
0
answers
24
views
Add a distinct number with a foreign Key in PHP MySQL
This is our table
I made a recursive function in my code that I wouldn't have duplicate entries, but as you see there is a slip-up, does anyone know what I can do to have a unique entry for the "...
4
votes
1
answer
2k
views
Use of LIMIT in Recursive Common Table Expression is not allowed in MySQL
My goal is to construct a tree using newest MySQL's WITH RECURSIVE method.
My table is called categories which has 2 rows. The ID and the parentID row.
My Categories Table:
. ID . | ParentID
---...
0
votes
2
answers
182
views
MySQLi Repeat Row Depending on Column Quantity Value
I have created a simple SQL statement to display which products customers have purchased from a woo commerce store.
This is working great but i'm struggling to find a SQL function that repeats rows ...
3
votes
4
answers
762
views
How can i get records of id those are connected in multiple row value
Following is my table
Id User_id type content item_id secondary_item_id
879 1 activity_comment Amazing 833 833
907 168 ...
1
vote
1
answer
679
views
How to select downline users using mysql query?
I want to select downline users against a user id.
This is my table structure:
"userid", "sponsorID", "username"
And the data into the table is:
1, 0, noman
2, 1, jani
3, 2, usman
4, 3, hassan
5, 4,...
1
vote
1
answer
186
views
Get names of parents recursively
I have a database that looks like this:
CREATE TABLE Persons (
id int,
parentID int,
name varchar(255)
);
INSERT INTO Persons (id, parentID, name) VALUES ('1', '0', 'smith');
INSERT INTO ...
9
votes
2
answers
1k
views
finding shortest path up to ten degrees of separation
I have the following three tables in SQL:
select * from movie limit 2;
id | title | year | content_rating | duration | lang | country | gross | budget ...