Skip to content

mySQL SELECT using a foreign key in another table

I’m having a hard time finding this answer so I’m hoping you guy can help me out. I have two tables: event_list with columns ‘id’, ‘name’, ‘date’ and event_default with one column ‘default_id’ …

How can I prevent 2nd order SQL attacks?

I’m using PHP PDO for my queries, everywhere, but I read that in very rare cases there could still be “second order injections” where an unsafe variable is stored then executed when used in another statement. Will prepared statements still protect against this? As long as I make sure I alway…

SQL Command not properly ended?

I am using a SQL statement with a Temporary relation, and am getting the error ORA-009933: SQL command not properly ended I don’t see anything wrong with the statement, so any assistance is greatly …

Delete row if table exists SQL

I have a script that drops a load of tables using DROP TABLE IF EXISTS, this works. There is also a delete in this script to DELETE a row from another table that I do not manage. This table may or …

SQLite in Android How to update a specific row

I’ve been trying to update a specific row for a while now, and it seems that there are two ways to do this. From what I’ve read and tried, you can just use the: execSQL(String sql) method or the: update(String table, ContentValues values, String whereClause, String[] whereArgs) method. (Let me kno…

SQL: Join tables on substrings

I have a table A with the string-column a and a table B with the string-column b. a is a substring of b. Now I want to join the the two tables on a and b. Is this possible? I want something like this: Select * from A,B where A.a *”is substring of”* B.b How can I write this in

Clarification of Java/SQLite batch and auto-commit

I copied the following example from an SQLite Java library website: I’m struggling to understand the significance of toggling autoCommit() either side of executeBatch(). Does it merely prevent a commit being made for each individual batch operation? Thus a single ‘bulk’ commit is will be mad…

See whether an item appears more than once in a database column

I want to check if a piece of data appears more than once in a particular column in my table using SQL. Here is my SQL code of what I have so far: salesid is the column I wish to check for, any help would be appreciated, thanks. Answer It should be: Regarding your initial query: You cannot do a