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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:28:02+00:00 2026-05-20T18:28:02+00:00

I have a SQL table, which looks like this: id_question (int) | tags (varchar)

  • 0

I have a SQL table, which looks like this:

id_question (int) | tags (varchar)
where “tags” field is
– either empty : NULL
– or is filled with one value (Ex: 1) (not numeric)
– or is filled with several comma separated values (ex: 273,2308,24) (not numeric)

id_question (int) | tags (varchar)
1 | 1,373
2 | 283,4555,308,12
3 | 283,25,3

ANd i have a blacklisted_tags array.
I would like to retrieve id_questions of all questions whose tags field do not have a blacklisted $tags_blacklist value.

For example:
$tags_blacklist = array (1,3)
=> I should get 2
and not 1 because it has 1 in its tags field
and not 3 because it has 3 in its tags field.

What should my SQL query look like?

  • 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-20T18:28:03+00:00Added an answer on May 20, 2026 at 6:28 pm

    your database design violates law of normalization #1: NEVER STORE COMMA-SEPARATED LISTS.

    What you should have instead is this:

    • id | tag
    • 1 | 1
    • 1 | 373
    • 2 | 283
    • 2 | 4555
    • 2 | 308

    etc.

    This way your query becomes as easy as

    SELECT DISTINCT id 
    FROM YourTable
    WHERE tag NOT IN (1, 3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a SQL server database, I have a table which contains a TEXT field
I have a table in SQL Server 2005 which has three columns: id (int),
I have a SQL table which has a number of fields ID | Value
I have a sql table which have the following data, Id City Country ---
I have a T-SQL table variable (not a table) which has an auto incrementing
Can we have a SQL query which will basically help in viewing table and
in context of SQL Server 2005, I have a table for which the primary
I have a database (NexusDB (supposedly SQL-92 compliant)) which contains and Item table, a
I have a SQL table with news stories and Unix timestamps. I'd like to
I have a SQL table like so: Update: I'm changing the example table as

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.