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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:42:42+00:00 2026-05-28T03:42:42+00:00

i have one query that need some changes, and i don’t get any clue

  • 0

i have one query that need some changes, and i don’t get any clue to do this :

this is my query :

select * from user_data a
left join user_group b 
on (a.role like b.role)

actually role value in userdata is (varchar)‘staff’

and role value in group is (varchar)‘staff;security;finance’

so i don’t get result what i expected ..

i imagine the query should be similar to this :

select * from user_data a
left join user_group b 
on (b.role like a.role+";%") // using wildcard

and i still don’t know the right query using wildcard to this case

any one can help?

  • 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-28T03:42:43+00:00Added an answer on May 28, 2026 at 3:42 am

    You can use CONCAT:

    select * from user_data a
    left join user_group b 
    on (b.role like CONCAT(a.role,";%")) // using wildcard
    

    Note – does b.role only have to match a.role at the beginning? what if it was security;staff;finance? You could do CONCAT('%',a.role,'%').

    You could do CONCAT('%','a.role','%') to handle matching a.role at any position, but only if you can be sure that you won’t have nested roles.
    For example: if b.role is staff and a.role is finance;gardenstaff;security, then this row will be returned from the query even though the role is gardenstaff and not staff.

    As an alternative, you can use RLIKE instead of LIKE. This is basically a regular-expressions verson of LIKE.

    In particular, the regex [[:<:]]staff[[:>:]] will match the whole word staff. The [[:<:]] and [[:>:]] stand for word boundaries, which stop you from matching the staff in gardenstaff.

    So, your query could be:

    select * from user_data a
    left join user_group b 
    on (b.role RLIKE CONCAT('[[:<:]]',a.role,'[[:>:]]'))
    

    And this would work for b.role being anywhere in the semicolon-separated a.role.

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

Sidebar

Related Questions

I have a query that pulls up questions from one table and answers from
I am trying to make one query, to get some statistic data from database.
I have a query that updates one record, and only one record. Is there
I have a query that always returns one row, with many columns. I would
I have a query that returns one row. However, I want to invert the
I have a query that returns a result set similar to the one below:
I have a sub query that returns one column, showing as GroupType, I then
I have a query that shows me a listing of ALL opportunities in one
I have a sql query that runs super fast, around one second, when not
We're using SQL Server 2000 Query Analyser, and one issue we have is that

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.