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

  • SEARCH
  • Home
  • 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 6541029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:03:13+00:00 2026-05-25T11:03:13+00:00

table1 has the columns: id name value event 1 name1 0.5 f 2 name2

  • 0

table1 has the columns:

id name  value event
1  name1  0.5   f
2  name2  1.9   f
3  name3  2.6   f
4  name4  0.2   f
5  name5  0     r
6  name6  text  r
7  name7  text2 t
8  name8  5     t
....
999  name999 4.7  f

table2 has the columns

id risk     value
1  very low 0
1  low      0.5
2  medium   1.5
3  high     2.5
4 very high 3

result:

1  name5    very high
2  name6    very high
3  name999  high
4  name3    high
5  name2    medium
6  name1    low
7  name7    very low
8  name8    very low

the query so far is (without the event of r and t to give very high and very low is):

    SELECT table1.id
     , table1.event
     , table2.risk 
    FROM table1
     JOIN table2
      ON table2.value = ( SELECT MAX(table2.value)
                   FROM table2
                   WHERE table2.value <= table1.value
                 )
    ORDER BY table1.value DESC
  • 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-05-25T11:03:14+00:00Added an answer on May 25, 2026 at 11:03 am
    SELECT table1.id, table1.name,
       CASE table1.event
         WHEN 'r' THEN 'very high'
         WHEN 't' THEN 'very low'
         ELSE (SELECT table2.risk FROM table2 WHERE table2.value <= table1.value
               ORDER BY table2.value DESC LIMIT 1)
       END AS risk
    FROM table1
    ORDER BY FIELD( table1.event, 'r', 'f', 't' ), table1.value DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table without IDs. it has 3 columns: the name of a
My output for my table in HTML has several columns such as userid, name,
I have two tables; Leads, Territories and Referrers. Lead has columns: ID, Name, TerritoryId
I have two tables: table1, table2. Table1 has 10 columns, table2 has 2 columns.
Imagine I have this simple table: Table Name: Table1 Columns: Col1 NUMBER (Primary Key)
I have user and user_role tables. The user_role table has two columns: user_id role_name
Suppose a database table has a column Name which is defined as key for
I have a table TreeStructures wich holds structures of Trees. This table has columns
if i have a table which has columns with fixed lenght, Will mySQL count
I have 2 tables: Lecturer and Department . The Lecturer table has these columns:

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.