[Solved] How to Update this data using SQL? [duplicate]

Something like this will work: UPDATE yourtable SET yourfield = MID(yourfield,INSTR(yourfield,”/Documents/”)); INSTR locates the position of the string /Documents/, and MID gets everything beginning from there. Notes: This maybe won’t work as you expect it when you have something like /Documents/Documents/ in your path string. Depending on your RDBMS MID and INSTR may not be … Read more

[Solved] SQLite delete last string – app crashed

I’ve solved this, thanks all // Deleting single contact public void deleteLastMessage(SubliminalMsg a) { SQLiteDatabase db = this.getWritableDatabase(); db.delete(TABLE_NAME, KEY_MSG + ” = ?”, new String[] { String.valueOf(a.get_message()) }); db.close(); } public String getLastString() { String selectQuery = “SELECT * FROM ” + TABLE_NAME; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); cursor.moveToLast(); LastString … Read more

[Solved] Error in my first table in kotlin

@laalto is right, you need to re-create your table once you’ve dropped it, you need to add a call to onCreate(p0) inside your onUpgrade() method. I removed a couple of unneeded fields on your class, this is how it looks now: class DbManger(context: Context) { val dbName = “MyNotes” val dbTable = “Notes” val colID … Read more

[Solved] Problem doing multiplication operation in a select between a float and an integer in sqlite [closed]

Sqlite uses ., not , for the decimal point in a floating pointer number (Do any sql databases accept a comma for it?). When you multiply a number (4) by a string (‘99,99′) the leading numeric portion of the string is converted to a number, so you’re seeing the result of 4 * 99. (SELECT … Read more

[Solved] SQLiteOpenHelper.getReadableDatabase() method is crashing

Thank you all…i’ve found the answer….i was calling the getAccountById method from a fragment…so i must re-pass the Context again to it UpdateAccountFragment a = new UpdateAccountFragment(accountID,getActivity()); and the constructor of the UpdateAccountFragment look like public UpdateAccountFragment (int accountID , Context context) { this.context = context; this.accountID = accountID; } 1 solved SQLiteOpenHelper.getReadableDatabase() method is … Read more

[Solved] Create condition that searches between two different WHEREs in the table

You can do the test for whether it’s home or away in the query itself. cursor.execute(“”” SELECT CASE WHEN robot_on_her_island = ? THEN ‘Last_War_on_her_island’ ELSE ‘Last_War_on_island_away’ END AS which_island, points_war_home, points_war_away FROM war WHERE ? IN (robot_on_her_island, robot_on_island_away) LIMIT 1″””, (select_robot_on_her_island, select_robot_on_her_island)) row = cursor.fetchone() if row: which_island, points_home, points_away = row if which_island == … Read more

[Solved] How to delete all Table records in Sqlite?

You should first initialize you SQLiteDatabase, so convert this: SQLiteDatabase database; database.delete(ActivityTableDBOpenHelper.ACTIVITY_TABLE,null,null); to this: SQLiteDatabase database = new SQLiteDatabase(this); // or dbHelper.getWritableDatabase(); if you have a dbHelper database.delete(ActivityTableDBOpenHelper.ACTIVITY_TABLE,null,null); Else the database object is null and you get the error. Here you could find a whole example for all operations http://www.vogella.com/tutorials/AndroidSQLite/article.html 2 solved How to delete … Read more

[Solved] I am getting this error on my code [closed]

The issue you have is that the SQL has a syntax error which is caused by the column definition on Tuesday INTEGER. ON is an SQLite keyword so it cannot be a column name unless forced e.g. [on] Tuesday INTEGER would work (although the column type will be Tuesday INTEGER, which is probably not an … Read more

[Solved] In sqlite I would do, But how in mongodb c#

You can get some inspiration for updating a document in the quick-tour documentation provided on the MongoDB site: http://mongodb.github.io/mongo-csharp-driver/2.5/getting_started/quick_tour/ Just look at the Updating Document section. But to save a click you can use the following code as an inspiration: // Setup the connection to the database var client = new MongoClient(“mongodb://localhost”); var database = … Read more

[Solved] TutorialsPoint – Flask – SQLAlchemy not working

The tutorial has an indentation problem in the student class. The constructor code should be indented one level so it becomes a method of the student class. Corrected code: (note the indent of “def init(self, name, city, addr,pin):” in the code below) class students(db.Model): id = db.Column(‘student_id’, db.Integer, primary_key = True) name = db.Column(db.String(100)) city … Read more

[Solved] Find all records which does not exist in table sqlite [closed]

Left join input list to the target table/column and keep rows having NULL in the fields from the “words” table. WITH query_input(word) AS ( VALUES (‘word 1’), (‘word 2’), (‘word 0’), (‘word 3’), (‘word 5’) ), — Remove this CTE when querying against your db. dict(id, word, definition) AS ( VALUES (1, ‘word 1’, ‘definition … Read more

[Solved] Fetching Data from Sqlite Database to TableLayout in Android

How about you try this public List<Registration> getList(SearchReport sc) List<Registration> crReg = new ArrayList<Registration>(); String selectQuery = “SELECT * FROM ” + TABLE_REGISTRATION + ” WHERE ” + DATE_COLUMN + ” BETWEEN ” + sc.getFrom() + ” AND ” + sc.getUntil() + ” AND ” + sc.getName(); SQLiteDatabase db = this.getReadableDatabase(); Then List<Registration> src = … Read more