Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
MySQL how to reverse where?

I have a table like this

id path
1 /
2 /a/
3 /a/b/
4 /a/b/c/
5 /a/b/c/d

When I use a path (e.g., path = '/a/b/c/') in the where clause, I would like to retrieve the children of this path.

e.g.:

id path

id path
1 /
2 /a/
3 /a/b/
4 /a/b/c/

how can I achieve this?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You could use the instr function

SELECT *
FROM   mytable
WHERE  INSTR('/a/b/c', path) = 1
over 4 years ago · Santiago Trujillo Report

0

I think you can use LIKE for find child or parent in next way:

-- select childs of /a/b/

select *
from paths 
where path like ('/a/b/%');

-- select parents of /a/b/

select *
from paths 
where '/a/b/' like concat(path,'%');

Test SQL LIKE online

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!