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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:11:41+00:00 2026-06-02T21:11:41+00:00

UPDATED Finally I used this way to get filtered result. SELECT * FROM statuses

  • 0

UPDATED

Finally I used this way to get filtered result.

SELECT * FROM statuses WHERE _id NOT IN (
    SELECT DISTINCT statuses._id FROM statuses, filtered_sources WHERE statuses.source LIKE '%'||filtered_sources.text||'%'
    UNION
    SELECT DISTINCT statuses._id FROM statuses WHERE statuses.screen_name IN(SELECT filtered_users.text FROM filtered_users)
    UNION
    SELECT DISTINCT statuses._id FROM statuses, filtered_keywords WHERE statuses.text LIKE '%'||filtered_keywords.text||'%'
);

Why I use this way instead of combine results directly?

I’d like to use query() method rather than rawQuery() in Android.

@zapi and @sixfeetsix , thank you very much, your answers give me this idea !

Download sqlite database for test here http://db.tt/ZsEwE9TV

I have a sqlite database contains three tables : statuses, filtered_keywords, filtered_sources.

Columns in each tables:

statuses:

|_id|text|source|

filtered_keywords and filtered_sources:

|_id|text|

now I’d like to filter query results from statuses contains words in filtered_keywords and filtered_sources.

I know I can use LIKE in sqlite, but I can’t use it like IN function.

SELECT * FROM statuses WHERE text in (SELECT text FROM filtered_sources);

So I have to query all data in filtered_sources and filtered_keywords as Cursor first, then build a long where clause, it’s really slow.

Is there any simple way to get the filtered result ?

  • 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-02T21:11:42+00:00Added an answer on June 2, 2026 at 9:11 pm

    You can do something like this:

    SELECT statuses.* 
    FROM statuses, filtered_sources
    WHERE statuses.text LIKE '%' || filtered_sources.text || '%'
    UNION
    SELECT statuses.*
    FROM statuses, filtered_keywords
    WHERE statuses.text LIKE '%' || filtered_keywords.text || '%';';
    

    For example:

    create table statuses (_id, text, source);
    create table filtered_keywords (_id, text);
    create table filtered_sources (_id, text);
    
    insert into statuses values (1, 'foobar', NULL);
    insert into statuses values (2, 'foofoobar', NULL);                              
    insert into statuses values (3, 'foofoobarbar', NULL);
    
    insert into filtered_keywords values (1, 'foofoo');
    insert into filtered_sources values (1, 'barbar');
    
    .headers on
    .mode column
    .width 3 15 6 
    
    SELECT statuses.* 
    FROM statuses, filtered_sources
    WHERE statuses.text LIKE '%' || filtered_sources.text || '%'
    UNION
    SELECT statuses.*
    FROM statuses, filtered_keywords
    WHERE statuses.text LIKE '%' || filtered_keywords.text || '%';';
    

    outputs:

    _id  text             source
    ---  ---------------  ------
    2    foofoobar              
    3    foofoobarbar           
    

    UPDATE:

    I updated the SELECT statement as the OP points out that the previous version didn’t work when one of the two filtered_* tables is empty.

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

Sidebar

Related Questions

UPDATED QUESTION Since the ctor is not supported by .NETCF (public FileStream(IntPtr handle, FileAccess
In the CLR (the runtime used by C#, VB.NET, etc.) there's a way of
I have used this tutorial before for adding registration fields to the Magento registration
This post has been heavily edited and updated! The Intent: I am writing an
I am struggling to get my Java program to run on AIX. I used
I've started working with ASP.net AJAX (finally ☺). and I've got an update panel
UPDATED: Added one more question (Question #4). Hi all, I'm building myself a custom
Updated question, see below I'm starting a new project and I would like to
UPDATED See post #3 below. There is a need to upload a file to
Updated Appears to be a precedence error and nothing to do with the question

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.