SQLite – UPSERT *not* INSERT or REPLACE

Assuming three columns in the table: ID, NAME, ROLE BAD: This will insert or replace all columns with new values for ID=1: BAD: This will insert or replace 2 of the columns… the NAME column will be set to NULL or the default value: GOOD: Use SQLite On conflict clause UPSERT support in SQLite! UPSERT syntax was added to … Read more

How to drop all tables from a database with one SQL query?

Use the INFORMATION_SCHEMA.TABLES view to get the list of tables. Generate Drop scripts in the select statement and drop it using Dynamic SQL: Sys.Tables Version Note: If you have any foreign Keys defined between tables then first run the below query to disable all foreign keys present in your database. For more information, check here.

Oracle Apex column link from LOV values

I’m mostly used to Apex 4.1, but this approach should work. You don’t need an LOV. Your report query should include both the MAST_ID and the TASK_NAME columns. Hide the TASK_NAME column and set MAST_ID as the linking column. If you set the Link Text (under Column Link) to #TASK_NAME#, you should get the desired result. Display As should be left at the default (Display as Text etc).

mysql Foreign key constraint is incorrectly formed error

I ran into this same problem with HeidiSQL. The error you receive is very cryptic. My problem ended up being that the foreign key column and the referencing column were not of the same type or length. The foreign key column was SMALLINT(5) UNSIGNED and the referenced column was INT(10) UNSIGNED. Once I made them both the same … Read more

SQL – HAVING vs. WHERE

WHERE clause introduces a condition on individual rows; HAVING clause introduces a condition on aggregations, i.e. results of selection where a single result, such as count, average, min, max, or sum, has been produced from multiple rows. Your query calls for a second kind of condition (i.e. a condition on an aggregation) hence HAVING works correctly. As a rule of thumb, use WHERE before GROUP BY and HAVING after GROUP BY. … Read more

In SQL Server, what does “SET ANSI_NULLS ON” mean?

It means that no rows will be returned if @region is NULL, when used in your first example, even if there are rows in the table where Region is NULL. When ANSI_NULLS is on (which you should always set on anyway, since the option to not have it on is going to be removed in the future), any comparison operation where (at least) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)