Skip to main content

All Questions

Tagged with
1 vote
0 answers
105 views

PHP recursive query based on sql select

I have 2 tables in a MariaDB Table 1 structure: ID (primary auto-increment) itemType(ENUM) and itemName(varchar) The ENUM has 4 possibilities - "heading","section","text",...
Russell Parrott's user avatar
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 ...
TheCHE's user avatar
  • 1
0 votes
2 answers
252 views

Recursive function count In laravel

Please help me out with the Recursive function in the model, I want a count on multilevel subcategories. $userChild = Referral::with(['get_children'])->where('user_id',Auth::id())->get();
Tanuja Pathania's user avatar
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 ...
Amin Arjmand's user avatar
0 votes
0 answers
170 views

How to stop recursive function php [laravel]

I use Laravel, I have table tbl_menu //In model: public function child() { return $this->hasMany('App\Menu', 'parentID', 'ID'); } //in controller public function getCountChild() ...
TinhTN's user avatar
  • 1
-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 ...
Austin's user avatar
  • 11
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;" ...
alex's user avatar
  • 608
1 vote
1 answer
812 views

Exclude directories & files from RecursiveDirectoryIterator

I'm trying to ZIP a folder and all its files and subfolder EXCEPT some files and folders. I have an array of files and folders to exclude. Works for the files, but folders in the exclude array are ...
Jerome Boccon-Gibod's user avatar
1 vote
1 answer
429 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 ...
Anmol singh's user avatar
-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 ║...
ab-oc's user avatar
  • 49
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 ...
Ranjeet Thorat's user avatar
-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 ...
user2468312's user avatar
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 "...
Dohan Smit's user avatar
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 ---...
Petros Nicolaou's user avatar
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 ...
Simon's user avatar
  • 59

15 30 50 per page
1
2 3 4 5