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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:04:09+00:00 2026-06-13T12:04:09+00:00

I have an issue with NOT LIKE statement. I have two sql tables setup

  • 0

I have an issue with NOT LIKE statement. I have two sql tables setup as tag map. First table finds tag_id according to the search name and second finds resource_id based on tag_id found. When I run a NOT LIKE statement below, I receive the result: resource_id = 1.

Tag map tables

tag_id name
1      meat
2      vegetarian

resource_id tag_id
1           1
1           2

Query

SELECT 
    f.id, f.food_name, tm.resource_id, tm.tag_id, t.name 
FROM 
    tag as t, tagmap as tm JOIN item as f ON 
    (
        f.id = tm.resource_id AND tm.tag_id IN 
        (
        SELECT 
            t.tag_id 
        FROM 
            tag as t 
        WHERE 
            t.name NOT LIKE '%meat%' 
        ) 
     )
GROUP by f.id

All I need this query to do is, if it finds a resource_id with tag name “meat” I don’t want it to return this resource_id.

If my explanation is not clear please let me know.

  • 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-13T12:04:09+00:00Added an answer on June 13, 2026 at 12:04 pm

    Then you must search for:

    select resource_id
    from tagmap
    where resource_id not in (select resource_id
                              from tagmap
                              where tag_id in (select tag_id from tag
                                               where name like '%meat%'));
    

    or with a join:

    select *
    from tagmap
    where resource_id not in (select m.resource_id
                              from tagmap m, tag t
                              where m.tag_id = t.tag_id and t.name like '%meat%');
    

    You look for resource_id with name “meat” and exclude these not in in your select.

    This might correspond to your query, but I’m not really sure:

    select f.id, f.food_name, tm.resource_id, tm.tag_id, t.name 
    from tag as t, tagmap as tm, item as f
    where f.id = tm.resource_id
          and tm.tag_id = t.tag_id
          and tm.resource_id not in (select m.resource_id
                                     from tagmap m, tag t
                                     where m.tag_id = t.tag_id
                                           and t.name like '%meat%')
    group by f.id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple SQL Server 2008 database with two tables like this: TableA:
I have a complex SQL statement that I need to match up two table
I have two tables which I would like to join by ID field. I
I have a syntax issue with my use of GROUP_CONTACT. With a sql statement
Before delving into the issue, first I will explain the situation. I have two
I have a SQL SELECT statement which will not be known until runtime, which
I have an issue which I could not find answer for across the web.
I have an issue and NO it is not homework, it's just a programmer
I have an issue in firefox and not in IE, didn't think I'd hear
So I have an issue that I'm not 100% sure on how to solve.

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.