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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:21:30+00:00 2026-06-02T20:21:30+00:00

Two SQLite tables in my Android App: PoweredEquip which contains all powered equipment units

  • 0

Two SQLite tables in my Android App:

  • PoweredEquip which contains all powered equipment units and their associated trailer
  • Trailers which contain all trailers not currently tied to a powered unit

When populating these two tables, I need to only insert into the Trailers table if the VIN doesn’t exist in the PoweredEquip table. So in T-SQL, I would do something like

If Not Exists (Select VIN From PoweredEquip Where VIN = _VIN)
    Insert Into Trailers Values (.....)

Without having to do a Select on PoweredEquip, opening up a DataReader and checking if HasRows is False in order to do the Insert, I was hoping there was an If Not Exists (Select…) equivalent in SQLite.

  • 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-02T20:21:34+00:00Added an answer on June 2, 2026 at 8:21 pm

    There is no direct equivalent for that in SQLite. Inserts don’t support any conditions (unless you do it via INSERT INTO TABLE SELECT..’. It might be possible to build something similar with an INSTEAD OF INSERT trigger that does the insert or not based on a CASE. Or with an AFTER INSERT trigger that deletes rows that don’t belong into the table.

    untested:

    CREATE TRIGGER remove_bad AFTER INSERT ON Trailers BEGIN
        DELETE FROM Trailers WHERE NEW._VIN IN (SELECT VIN FROM PoweredEquip);
    END;
    

    Edit the way mentioned in the other answer should work too:

    INSERT INTO Trailers(columns, ..) SELECT 'values',.. WHERE NOT EXISTS 
        (SELECT 1 FROM PoweredEquip WHERE VIN = '_VIN-value');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So my Android app uses a SQLite database. I need to replicate two or
I have two tables in a SQLite DB, INVITEM and SHOPITEM. Their shared attribute
I have two SQLite tables, recipes and ingredients. I need to find all of
I have two tables in a SQLite DB, and both have the following fields:
I am trying to create an application which requires a two table SQLite database
Here is my code for my db class: package one.two; import java.util.List; import android.app.ListActivity;
here is my Arrival.java package one.two; import java.io.IOException; import java.util.ArrayList; import java.util.List; import android.app.ListActivity;
Here is my Arrival.java package one.two; import java.io.IOException; import java.util.ArrayList; import java.util.List; import android.app.ListActivity;
I got sqlite DB on my android app to save reservations. The one of
We've got an android app and an iPhone app (same functionality) that use sqlite

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.