Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7918719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:36:17+00:00 2026-06-03T15:36:17+00:00

i have field in mysql type varchar with field data contains code, and the

  • 0

i have field in mysql type varchar with field data contains code, and the code is like tree structure with dot (.) as separator between parent and child.

Example 1215 has child 1215.001 and 1215.002

And this is the data each row on database

ID  | kode
1   | 1215
2   | 1215.001
3   | 1215.001.001
4   | 1215.002.001
5   | 1215.002
6   | 1215.002.001

How to get the level 2 code?
which its mean will be only the code 1215.001 and 1215.002

Already tried with this query

select * from `kegiatan` where `kode` LIKE '1215.%';

But it get all the code start with 1215 eg: 1215.001.001

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:36:18+00:00Added an answer on June 3, 2026 at 3:36 pm

    Use a regular expression.

     select * from `kegiatan` where `kode` REGEXP '^1215\.[^\.]+$';
    

    This will match everything:

     That starts with ( "^" )
    
     the string "1215.",
    
     followed by at least one character that is a member of the set "NOT ." ("[^\.]+")
    
      followed by the end of the string.("$")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have varchar data type field in mysql db. I want to treat space
I have a mysql table field set as time type which stores data in
hi all i have a field ammount in mysql database which have varchar(50) type.
I have a table like this mysql> desc user_changes; +----------+--------------+------+-----+---------+-------+ | Field | Type
I have a MySQL field URL of type Varchar. Is it possible with one
I have a table with a field of type date within a MySQL database.
I have a table abc with a field datetime_abc type-> DATETIME in mysql. and
Let's say I have this MySQL table: OK.. see the type field? Type 0
I have the following MySQL table structure: num field company phone website 1 Gas
I have this two tables: mysql> desc vat_rates; +-------------+---------------+------+-----+---------+-------+ | Field | Type |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.