Skip to content

Tag: sql

SQL select * from column where year = 2010

This is probably a simple where clause but I want to say, from columnX (which is datetime) I want all rows where just the year = 2010. so: Answer Regarding index usage (answering Simon’s comment): if you have an index on Columnx, SQLServer WON’T use it if you use the function “year” (o…

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…

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