CodeCap
TRENDING
  • Home
  • PHP
  • PYTHON
  • ANDROID
  • JAVA
  • WORDPRESS
  • ARTICLES
  • TUTORIAL
No Result
View All Result
  • Home
  • PHP
  • PYTHON
  • ANDROID
  • JAVA
  • WORDPRESSNew
  • ARTICLES
  • TUTORIAL
SUBSCRIBE
  • Home
  • PHP
  • PYTHON
  • ANDROID
  • JAVA
  • WORDPRESSNew
  • ARTICLES
  • TUTORIAL
No Result
View All Result
CodeCap
No Result
View All Result
Home PHP Programming

How to get filename from file path in MySQL?

How to get filename from file path in MySQL?

by asdevil666
May 6, 2021
in PHP Programming
0
How to generate UUID in Laravel?
26
SHARES
160
VIEWS
Share on FacebookShare on Twitter





Sometimes we require to get filenames from path of table column in MySQL. If you are working on PHP then you can simply use basename() pre-define function of code PHP, But in MySQL you can’t use basename() in select query. This mysql function you can use in code PHP, PHP framework like laravel, codeigniter etc.

However, you can get simply filename or image name from path using SUBSTRING_INDEX() of MySQL. You can extract filename from path using substring_index(), substring_index() take three argument, first for column name, second for split string chat, and third get last element from split. So you can simply use. I am going to give you simply example for getting filenames from path or url.

In this example i have “categories” table with six columns i also added some dummy data on table as listed bellow :

categories table:

Ok, now i have image column with full path of image, we require only get name of image not path so run bellow mysql query using substring_index().

MySQL Query:

Read Also: How to import CSV file using mysql

SELECT id, name, SUBSTRING_INDEX(image, '/', -1) FROM `categories`

After this, you will see output like as bellow screen shot:

Output:

I hope it can help you….

Post Views: 640
Share10Tweet7Share3

Related Posts

How to generate UUID in Laravel?
PHP Programming

How can i print php variable in jquery?

May 6, 2021
How to generate UUID in Laravel?
PHP Programming

How to create database seeder in Laravel 5.7?

May 6, 2021
How to generate UUID in Laravel?
PHP Programming

Laravel Many to Many Polymorphic Relationship Tutorial

May 6, 2021
How to generate UUID in Laravel?
PHP Programming

How to create scroll to top of the page by jquery animate ?

May 6, 2021
How to generate UUID in Laravel?
PHP Programming

Create Dynamic Treeview Example using JQuery Ajax in PHP MySQL

May 6, 2021
How to generate UUID in Laravel?
PHP Programming

Laravel – Category Treeview Hierarchical Structure Example with Demo

May 6, 2021
Next Post
How to generate UUID in Laravel?

Laravel Many to Many Polymorphic Relationship Tutorial

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

I agree to the Terms & Conditions and Privacy Policy.

Search

No Result
View All Result

Categories

  • Android Programming
  • Android Tutorial
  • Articles
  • Business Traveller
  • Destinations
  • Extreme Work
  • General News
  • Insider Guides
  • JAVA Programming
  • JAVA Tutorial
  • PHP Error Resolve
  • PHP Programming
  • PYTHON Programming
  • PYTHON Tutorial
  • Tutorial
  • Wordpress

Tags

alert alertbox android android error application array auto autocomplete autocomplete off coding confirm box development error features form form alert function function call inspiration in_array java java error java pages javascript mobile app myql mysqli error news off php php error programming python python programming shortcode software standard
Facebook Twitter LinkedIn Youtube RSS

About Us

Codecap is the best programming for the new generation for learning and development

  • 121 King Street, Melbourne
    VIC 3000, Australia
  • codecap666@gmail.com
  • 888-123-4567

Categories

  • Android Programming
  • Android Tutorial
  • Articles
  • Business Traveller
  • Destinations
  • Extreme Work
  • General News
  • Insider Guides
  • JAVA Programming
  • JAVA Tutorial
  • PHP Error Resolve
  • PHP Programming
  • PYTHON Programming
  • PYTHON Tutorial
  • Tutorial
  • Wordpress
VIDEO: Is There Enough Programming Variability For Week 1 of the 2022 CrossFit Semifinals? – Morning Chalk Up
Tutorial

VIDEO: Is There Enough Programming Variability For Week 1 of the 2022 CrossFit Semifinals? – Morning Chalk Up

by asdevil666
May 21, 2022
0

The stage is set for week 1 of Semifinals now that we see the complete picture of programming and the...

Read more
Football: Ohio State announces times, programming updates for three games – OSU – The Lantern

Football: Ohio State announces times, programming updates for three games – OSU – The Lantern

May 21, 2022
Fox, Tubi Unveil Three New Animated Films, 2022-23 Programming Slate – Cartoon Brew

Fox, Tubi Unveil Three New Animated Films, 2022-23 Programming Slate – Cartoon Brew

May 21, 2022
TelevisaUnivision Reveals Upcoming Programming: Sofia Vergara Animated Series, Selena Quintanilla Tribute Concert, More — Upfronts – Deadline

TelevisaUnivision Reveals Upcoming Programming: Sofia Vergara Animated Series, Selena Quintanilla Tribute Concert, More — Upfronts – Deadline

May 21, 2022
Baltimore City Schools Hosts Event For Summer Programming At Maryland Science Center – CBS Baltimore

Baltimore City Schools Hosts Event For Summer Programming At Maryland Science Center – CBS Baltimore

May 21, 2022

Creation by : AMTICY

No Result
View All Result
  • Home
  • PHP
  • PYTHON
  • ANDROID
  • JAVA
  • WORDPRESS
  • ARTICLES
  • TUTORIAL

Creation by : AMTICY

Ads Blocker Image Powered by Code Help Pro
Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Refresh