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 8101827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:05:03+00:00 2026-06-05T23:05:03+00:00

I have two tables: Table_A name1 create_date Table_B name2 keep_time name1 is something like

  • 0

I have two tables:

Table_A
name1
create_date

Table_B
name2
keep_time

name1 is something like xxxxxx-yyy and name2 is like xxxxxxx. name2 is exactly the first part of the name1 separated by ‘-‘.

I would like to get all the rows in Table_A, whose keep_time is less than (now – create_date).

As you understand, the problem is how I can split the name1 by ‘-‘ character and get the first part and get the keep_time from Table_B by corresponding name2.

I need to write SQL in MySQL for such query?

Thanks

  • 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-05T23:05:05+00:00Added an answer on June 5, 2026 at 11:05 pm

    If I’ve understood your requirements correctly:

    SELECT a.* FROM table_A a
      LEFT JOIN table_B b on b.name2 = SUBSTRING_INDEX(a.name1, '-', 1)
      WHERE DATEDIFF(NOW(), a.create_date) < b.keep_time  
    

    EDIT : DateDiff.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables that look like this: Table: cases id name status case_no
I have two tables, for example: Table A Table B ======= ======= Name |
I have two tables in a MySql DB: items id (char) name (varchar) description
I have two tables in a MySql database: COUNTRY --------------- id, country_name and CITY
I have the following two tables: Table1 ---------- ID Name 1 A 2 B
Say I have two tables called A (fields: id, phase, name) and B(fields: id,
I have two tables. indRailType contains a list of the names paired with an
I have two tables. One (Widgets) has a list of widgets (ID, widget_name, color,
I need some help with a MySQL query. I have two tables, one with
I have two tables salary_structures and payheads. Below are my table structures: create_table payheads,

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.